Do not check if .git folder exists
git commands will fail anyway if not present
This commit is contained in:
1 parent
99534e4eb9
commit
574af4b7fe
3 files changed
+3
-28
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in new issue
Block a user