From 5bef4e7a172ff0da50ca09dbb5a00c9afdaf49db Mon Sep 17 00:00:00 2001 From: Felix Bauer Date: Mon, 15 Jan 2018 18:02:24 +0100 Subject: [PATCH] Only consider added migrations --- django_migration_linter/migration_linter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index 69158ff..fcf8e2d 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -152,16 +152,16 @@ class MigrationLinter(object): def _gather_migrations_git(self, git_commit_id): migrations = [] # Get changes since specified commit - git_diff_command = 'cd {0} && git diff --name-only {1}'.format( + git_diff_command = 'cd {0} && git diff --name-status {1}'.format( self.django_path, git_commit_id) log.info('Executing {0}'.format(git_diff_command)) diff_process = Popen( git_diff_command, shell=True, stdout=PIPE, stderr=PIPE) for line in map( utils.clean_bytes_to_str, diff_process.stdout.readlines()): - # Only gather lines that include migrations + # Only gather lines that include added migrations if re.search( - '\/{0}\/.*\.py'.format(self.MIGRATION_FOLDER_NAME), + '^A.*\/{0}\/.*\.py'.format(self.MIGRATION_FOLDER_NAME), line) and \ '__init__' not in line: app_name, migration_name = self._split_migration_path(line)