Fix that linter actually ignores deleted files and add a specific test for this
This commit is contained in:
1 parent
5bef4e7a17
commit
fffdf5714e
60 files changed
+293
-7
No files matched your search
@@ -125,16 +125,16 @@ class MigrationLinter(object):
|
||||
Even if calling a shell is slow and ugly, for now,
|
||||
it allows to seperate the instances correctly.
|
||||
"""
|
||||
git_diff_command = (
|
||||
sqlmigrate_command = (
|
||||
'cd {0} && '
|
||||
'{1} manage.py sqlmigrate {2} {3} '
|
||||
'--database {4}').format(
|
||||
self.django_path,
|
||||
self.python_exe, app_name, migration_name,
|
||||
self.database)
|
||||
log.info('Executing {0}'.format(git_diff_command))
|
||||
log.info('Executing {0}'.format(sqlmigrate_command))
|
||||
sqlmigrate_process = Popen(
|
||||
git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
sqlmigrate_command, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
|
||||
sql_statements = []
|
||||
for line in map(
|
||||
@@ -164,6 +164,7 @@ class MigrationLinter(object):
|
||||
'^A.*\/{0}\/.*\.py'.format(self.MIGRATION_FOLDER_NAME),
|
||||
line) and \
|
||||
'__init__' not in line:
|
||||
line = line.split()[-1] # Remove the status letter
|
||||
app_name, migration_name = self._split_migration_path(line)
|
||||
migrations.append((app_name, migration_name))
|
||||
diff_process.wait()
|
||||
|
||||
+4
-1
@@ -38,6 +38,8 @@ MULTI_COMMIT_PROJECT = os.path.join(
|
||||
_FIXTURES_FOLDER, 'test_project_multi_commit/')
|
||||
CORRECT_PROJECT = os.path.join(
|
||||
_FIXTURES_FOLDER, 'test_correct_project/')
|
||||
DELETED_MIGRATION_PROJECT = os.path.join(
|
||||
_FIXTURES_FOLDER, 'test_deleted_migration_project/')
|
||||
|
||||
NOT_DJANGO_GIT_PROJECT = os.path.join(
|
||||
_FIXTURES_FOLDER, 'test_git_project/')
|
||||
@@ -46,7 +48,8 @@ NOT_GIT_DJANGO_PROJECT = os.path.join(
|
||||
|
||||
ALL_GIT_PROJECTS = (
|
||||
NOT_DJANGO_GIT_PROJECT,
|
||||
MULTI_COMMIT_PROJECT
|
||||
MULTI_COMMIT_PROJECT,
|
||||
DELETED_MIGRATION_PROJECT
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -116,10 +116,10 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
|
||||
self.assertTrue(lines[2].endswith('IGNORE'))
|
||||
|
||||
def test_call_linter_cmd_line_git_id(self):
|
||||
cmd = '{0} {1} d7125d5f4f0cc9623f670a66c54f131acc50032d'.format(
|
||||
cmd = '{0} {1} 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba'.format(
|
||||
self.linter_exec,
|
||||
fixtures.MULTI_COMMIT_PROJECT)
|
||||
fixtures.prepare_git_project(fixtures.MULTI_COMMIT_PROJECT)
|
||||
fixtures.DELETED_MIGRATION_PROJECT)
|
||||
fixtures.prepare_git_project(fixtures.DELETED_MIGRATION_PROJECT)
|
||||
|
||||
process = Popen(
|
||||
cmd, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
*.pyc
|
||||
__pycache__/
|
||||
*sqlite3
|
||||
@@ -0,0 +1 @@
|
||||
Delete file and insert new
|
||||
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
@@ -0,0 +1 @@
|
||||
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba
|
||||
@@ -0,0 +1,5 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = false
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
@@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
@@ -0,0 +1,3 @@
|
||||
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
|
||||
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
|
||||
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
|
||||
@@ -0,0 +1,3 @@
|
||||
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
|
||||
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
|
||||
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
x¥�;
|
||||
1@sŠéÅ%gC"ÀÎ:ŸY�kQ¯ïŠG°|¯x/I¥z\õÆ�s²dR´}ÐVóHqrÙzãÜ™ÉkRáÙ¯Òà^%oΛ¤vù‹Ãû‡‡K␍å>$©{Àí ‰`QkµØeÜù�„:5¹qêP¥«J>ñ
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
x]PËjÃ0ìÙ_±�ƒ�;Ôm øRrÈ·„m�ZY2zÒ¯¯dåY„˜™�™UÃee™?Ì }L¡•”‰~Öté«G¢¼£@U¤ÐaóU‹^B‘EöRÀ2/^Ò"O—%O«¼Œ:% ¤³Æ*$Ø0JeÀ
|
||||
æÌ‘pfœ×QÒÉ/£ÍY7°Þ…1)ô7à•QËka¦’«(»€óU�;L0Ãj|(‹£8¢ (Z†ÚŸ“ð89úí|à…ñ67o
|
||||
Ýú{_&™&=ï�¨¬âu¼¸C;†œê*„a¸“˜Ñø¼U¶¶Fn½4©Ý‹´S|錊␍µ:’o<ž�ÊmÅ~±Úºßs’T�ÔHB‰Ý&žÏï{øÐ$–s2UºFï„ÁUH÷‚)ãÿüájwr>Dqá£&
|
||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
x¥ŽKJD1Eg5›ü^> ¢àWª*mèÎK¢½}Ÿ¸g÷ÜÁáÐè½-°Á>¬)Õn”8PŽ"¹ZD'…LJ^2»èÅbv5IT7œ²/Ð.oTD‚®VД«·R˜½ËÙPª'ŽA~Ï1á¿?}Œ2]à™ñtÿÃ×sÇv=Ñè/`6œñÎZxÔFku¼Gè’(Ô3¤Ë'CÛå␍W+W�ÞÎó˜cW?hþVd
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
x]OÁj„0ì9_ñ \QÙ‚,xXºlÙÃÞz+"Ѽ•´1‘Dö뛘ݵÛwafÞ̼F¨¶ÅËÓ3¼¡DMGdÐÌpø¤²S�'i’�’�§Y±I³MV@žïò-!z`‹,a␍ð~Pz„žwÖƒ+ibèCa! ÆÀùF…«(¹ƒÑްÃ%9P»žÐc”eËÑXâcVžSƒ+íùñªÑ^uveÂeÓñn$í±öAü€^8
|
||||
fJâ…þ␍΂ÛUÉ~ÕÑICju»„°Ò•Žaм§z®¿p¾"µ½Šÿ`y¤ÂXÉ7êF¬}‰Ó!ˆ¢Ç.4ä$D½TZ£OrĵOw‚%ãÿ~µÚ]�+ò␍¢�m
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
xU�Ak„0…{öWìA·¨¨]l<JK½õVJˆf””8‘)ý÷Mâ®íæÞ¼yßK:¥;8ÕÅͲÛz-$�␍¬vȼà ␍·( û�§/N£†2/˼MPå}VYU»kswŠ£'`lXíj�1�Ó¬�…•¤G¦¤uij‰6£y¹è.¾IŽ&5-)LnÁ;£^ñe�·Ë(ù3å»xl¢Ü8# ¤^â-|Ñ’ØâbŸç8…¸(ŠŠq!á7#mJ±A¢ñ1␍KŸ[ žýó}£«¸…xö‹ÉÎò¼ÐžŸ°�y¼EzÝŸM␍h‡å�Â3úÚê´Û7ä¯dqD³‘|ÛöݬxîêC÷Ú¿ºÁ‹U
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
x]�ÍjÃ0„{ÖS,ô !«LÀ‡BHé¡·ÞJ1R´1
|
||||
òÊX
|
||||
¥oßHnÝŸ=ÎÎ~3k|0p×Ê›[xDÂY'´`>`Ö4PBŠ�’M»•ͶiA©�ºgì4‡l± kÀ�S˜Œn¸2\ XÃ,úÈ;z#<¯ª“XÅÍŽ1¸ŽÅ É"FèൈyQñ„1õzšx␍\JÙôŽ\rÚóM]\o!Lù�\áÏý¯Ðk½Vx(u{Ò#v\ó™õ<‹JøÞÓÅ{m<ö§Løg+Z·ü-ž(á€ó’”Ϻ—ù‚_]3tý ¡¢o�
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
x+)JMU04±`040031Qˆ�ÏÌË,‰�×+¨dx6÷ÑìM¯9{wk®+�ºqèIOðD¨²âÔ’’̼ôb�²)ûw—Ê<hý¶~ÇÑ3ËŠ*§Ÿõm†*+-Ê+)Ž}z»ûè÷š›O×�KÚúüÄm¶wP%åÅé™ S0°È.Ø~§å´ø¾ ‹¦ƒ)ÒE[^‚D_
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+3
@@ -0,0 +1,3 @@
|
||||
x]�ЭjУ0�{жS,є !ЋPLР�BHщЁЗоJ1RД1
|
||||
ђЪX
|
||||
ЅoпHnн�=ЮЮ~3k|0pзЪ�[xDТY'Д`>`ж4PB���MЛ�ЭЖiAЉ�Кgь4�lБ kР�S��nИ2\ XУ,њШ;z#<ЏЊ�XХЭ�1И�Х Щ"FшрЕ�yQё�1ѕz�x␍\Jйє�\rкѓM]\o!Lљ�\сЯ§ЏаkНVx(u{в#v\ѓ�ѕ<�JјогХ{m<іЇLјg+ZЗќ-�(с�ѓ��ЯК�љ�_]3t§ Ђ№o�
|
||||
+1
@@ -0,0 +1 @@
|
||||
x¥ŽAn1EYçÞ£¢1N2Œ„*Ü¡kÇvÚˆ™ JÓrýâ]¾÷¥§/uYJ‡c ]of@¢j^#“ž‚¤ƒ÷qœÐ&’ñdÂB¦ÁݹÙÚa[MrDœèD(a¦ØÛ8L)'�Èž}bÇ?ý«6¸òoÑ·�šZ•œõ‰‡Ç/Ÿ—ù uyߺ ½#ì·Ùíh·$ÜÕfë¹Ì¼*”õÛZ‡Õî7zRY
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
xm�AkĂ0…wöŻ>µĐĹt�íJÇÖÚ±câÄJęb[ÁVŰíß/I[ča'!žôľ'•ŽJx|xş“RŠďÍb …Ú6PSgcĚçm¤=V—š ±dŔź–&ŕÂyY;§K‡ hđdďŃÁQG;HA{4Pşmť4[
|
||||
EŃů˝uDOÁ†î(tć6AmN !Šs›ž•2TĄĚěuhčš©"Ż0¨i6ťŞť�”ÁÖŃŻÇŔꔫD¦°ľĄČ@I�:’‡łKVuđ¬�Ë@�ś÷}~UJ†ŁŤ˛„l°ÖÇ#9{]-ÖůfľÝ.W‹Mţąž}}Ěĺäđ?�Mîm‡Ó®íM؆&ɱ7 x�˙řٱř°č™ž
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
||||
be2fae887ee7ecd2d1e6371af1a865c17414bde9
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_deleted_migration_project.settings")
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError:
|
||||
# The above import may fail for some other reason. Ensure that the
|
||||
# issue is really that Django is missing to avoid masking other
|
||||
# exceptions on Python 2.
|
||||
try:
|
||||
import django
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
)
|
||||
raise
|
||||
execute_from_command_line(sys.argv)
|
||||
Whitespace-only changes.
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TestAppConfig(AppConfig):
|
||||
name = 'test_app'
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 2.0.1 on 2018-01-18 22:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='A',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('null_field', models.IntegerField(null=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.0.1 on 2018-01-18 22:26
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('test_app', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='a',
|
||||
name='new_nullable_field',
|
||||
field=models.IntegerField(null=True),
|
||||
),
|
||||
]
|
||||
Whitespace-only changes.
@@ -0,0 +1,6 @@
|
||||
from django.db import models
|
||||
|
||||
class A(models.Model):
|
||||
null_field = models.IntegerField(null=True)
|
||||
new_not_null_field = models.IntegerField(null=False)
|
||||
new_nullable_field = models.IntegerField(null=True)
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Whitespace-only changes.
+120
@@ -0,0 +1,120 @@
|
||||
"""
|
||||
Django settings for test_deleted_migration_project project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 1.11.6.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.11/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.11/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'gtb+mohs%gf0+#fr89vw7e&#edmv=q8!iv+n&j_soawk$tkj3^'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'test_app'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'test_deleted_migration_project.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'test_deleted_migration_project.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django_fake_database_backends.backends.mysql',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.11/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"""linter_test_project URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/1.11/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.conf.urls import url, include
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf.urls import url
|
||||
from django.contrib import admin
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
]
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for linter_test_project project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_deleted_migration_project.settings")
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in new issue
Block a user