From 75c969c6a9ae288660341a392a85cdcdfcc2962b Mon Sep 17 00:00:00 2001 From: David Wobrock Date: Sun, 20 Jan 2019 11:46:07 +0100 Subject: [PATCH] Revert "don't assume git root is django_path" This reverts commit c14f9aef37ccabebb6d9e267fde72398332830cb. --- django_migration_linter/migration_linter.py | 22 +-------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index ff2d726..808be46 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -195,28 +195,8 @@ class MigrationLinter(object): logger.info("Found {0} sql migration lines".format(len(sql_statements))) return sql_statements - def _get_git_root(self): - git_root = self.django_path - command = "cd {0} && git rev-parse --show-toplevel".format(self.django_path) - logger.info("Executing {0}".format(command)) - diff_process = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) - for line in map(clean_bytes_to_str, diff_process.stdout.readlines()): - git_root = line - diff_process.wait() - - if diff_process.returncode != 0: - output = [] - for line in map(clean_bytes_to_str, diff_process.stderr.readlines()): - output.append(line) - logger.error( - "Error while git rev-parse command:\n{}".format("".join(output)) - ) - raise Exception("Error while executing git rev-parse command") - return git_root - def _gather_migrations_git(self, git_commit_id): migrations = [] - git_root = self._get_git_root() # Get changes since specified commit git_diff_command = ( "cd {0} && git diff --relative --name-only --diff-filter=A {1}" @@ -229,7 +209,7 @@ class MigrationLinter(object): re.search(r"\/{0}\/.*\.py".format(MIGRATION_FOLDER_NAME), line) and "__init__" not in line ): - migrations.append(Migration(os.path.join(git_root, line))) + migrations.append(Migration(os.path.join(self.django_path, line))) diff_process.wait() if diff_process.returncode != 0: