diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index e00b6a0..999843f 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -134,12 +134,6 @@ class MigrationLinter(object): def lint_all_migrations(self, git_commit_id=None): # Collect migrations if git_commit_id: - if not utils.is_git_project(self.django_path): - raise ValueError( - ( - "The given project {0} does not seem " "to be versioned by git." - ).format(self.django_path) - ) migrations = self._gather_migrations_git(git_commit_id) else: migrations = self._gather_all_migrations() @@ -178,7 +172,7 @@ class MigrationLinter(object): it allows to seperate the instances correctly. """ sqlmigrate_command = ( - "cd {0} && " "{1} manage.py sqlmigrate {2} {3} " "--database {4}" + "cd {0} && {1} manage.py sqlmigrate {2} {3} " "--database {4}" ).format( self.django_path, self.python_exe, app_name, migration_name, self.database ) @@ -205,7 +199,7 @@ class MigrationLinter(object): migrations = [] # Get changes since specified commit git_diff_command = ( - "cd {0} && " "git diff --name-only --diff-filter=A {1}" + "cd {0} && git diff --name-only --diff-filter=A {1}" ).format(self.django_path, git_commit_id) logger.info("Executing {0}".format(git_diff_command)) diff_process = Popen(git_diff_command, shell=True, stdout=PIPE, stderr=PIPE) diff --git a/django_migration_linter/utils.py b/django_migration_linter/utils.py index 1efc5d7..5d34d1b 100644 --- a/django_migration_linter/utils.py +++ b/django_migration_linter/utils.py @@ -25,11 +25,6 @@ def is_django_project(path): return os.path.isfile(django_manage_file) -def is_git_project(path): - git_directory = os.path.join(path, ".git") - return os.path.isdir(git_directory) - - def is_directory(path): return os.path.isdir(path) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 28fb363..b997288 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -16,25 +16,11 @@ import os import unittest from tests import fixtures -from django_migration_linter.utils import is_django_project, is_git_project, is_directory, find_project_settings_module, \ +from django_migration_linter.utils import is_django_project, is_directory, find_project_settings_module, \ split_path, split_migration_path class UtilityFunctionTest(unittest.TestCase): - def tearDown(self, *args, **kwargs): - fixtures.clear_all_git_projects() - super( - UtilityFunctionTest, - self).tearDown(*args, **kwargs) - - def test_detect_not_git_project(self): - self.assertFalse(is_git_project(fixtures.NOT_GIT_DJANGO_PROJECT)) - - def test_detect_git_project(self): - project_path = fixtures.MULTI_COMMIT_PROJECT - fixtures.prepare_git_project(project_path) - self.assertTrue(is_git_project(project_path)) - def test_detect_django_project(self): self.assertTrue(is_django_project(fixtures.ADD_NOT_NULL_COLUMN_PROJECT))