Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce noprefix=no for git diff config #94

Merged
merged 1 commit into from
Mar 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 21 additions & 6 deletions diff_cover/git_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def diff_committed(self, compare_branch='origin/master'):
to stderr.
"""
return execute([
'git', '-c', 'diff.mnemonicprefix=no', 'diff',
"{branch}...HEAD".format(branch=compare_branch),
'git',
'-c', 'diff.mnemonicprefix=no',
'-c', 'diff.noprefix=no',
'diff', '{branch}...HEAD'.format(branch=compare_branch),
'--no-color',
'--no-ext-diff'
])[0]
Expand All @@ -41,8 +43,14 @@ def diff_unstaged(self):
Raises a `GitDiffError` if `git diff` outputs anything
to stderr.
"""
return execute(['git', '-c', 'diff.mnemonicprefix=no', 'diff',
'--no-color', '--no-ext-diff'])[0]
return execute([
'git',
'-c', 'diff.mnemonicprefix=no',
'-c', 'diff.noprefix=no',
'diff',
'--no-color',
'--no-ext-diff'
])[0]

def diff_staged(self):
"""
Expand All @@ -52,5 +60,12 @@ def diff_staged(self):
Raises a `GitDiffError` if `git diff` outputs anything
to stderr.
"""
return execute(['git', '-c', 'diff.mnemonicprefix=no', 'diff',
'--cached', '--no-color', '--no-ext-diff'])[0]
return execute([
'git',
'-c', 'diff.mnemonicprefix=no',
'-c', 'diff.noprefix=no',
'diff',
'--cached',
'--no-color',
'--no-ext-diff'
])[0]
19 changes: 11 additions & 8 deletions diff_cover/tests/test_git_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ def test_diff_committed(self):
self.assertEqual(output, 'test output')

# Expect that the correct command was executed
expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff',
'origin/master...HEAD', '--no-color', '--no-ext-diff']
expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c',
'diff.noprefix=no', 'diff', 'origin/master...HEAD',
'--no-color', '--no-ext-diff']
self.subprocess.Popen.assert_called_with(
expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE
)
Expand All @@ -41,8 +42,8 @@ def test_diff_unstaged(self):
self.assertEqual(output, 'test output')

# Expect that the correct command was executed
expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff',
'--no-color', '--no-ext-diff']
expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c',
'diff.noprefix=no', 'diff', '--no-color', '--no-ext-diff']
self.subprocess.Popen.assert_called_with(
expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE
)
Expand All @@ -55,8 +56,9 @@ def test_diff_staged(self):
self.assertEqual(output, 'test output')

# Expect that the correct command was executed
expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff', '--cached',
'--no-color', '--no-ext-diff']
expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c',
'diff.noprefix=no', 'diff', '--cached', '--no-color',
'--no-ext-diff']
self.subprocess.Popen.assert_called_with(
expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE
)
Expand All @@ -71,8 +73,9 @@ def test_diff_committed_compare_branch(self):
self.assertEqual(output, 'test output')

# Expect that the correct command was executed
expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff',
'release...HEAD', '--no-color', '--no-ext-diff']
expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c',
'diff.noprefix=no', 'diff', 'release...HEAD', '--no-color',
'--no-ext-diff']
self.subprocess.Popen.assert_called_with(
expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE
)
Expand Down
3 changes: 2 additions & 1 deletion diff_cover/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def _set_git_diff_output(self, stdout, stderr, returncode=0):
a phony directory.
"""
def patch_diff(command, **kwargs):
if command[0:4] == ['git', '-c', 'diff.mnemonicprefix=no', 'diff']:
if command[0:6] == ['git', '-c', 'diff.mnemonicprefix=no', '-c',
'diff.noprefix=no', 'diff']:
mock = Mock()
mock.communicate.return_value = (stdout, stderr)
mock.returncode = returncode
Expand Down