Skip to content

Commit

Permalink
Merge pull request #94 from beaugunderson/master
Browse files Browse the repository at this point in the history
Enforce noprefix=no for git diff config
  • Loading branch information
Bachmann1234 committed Mar 16, 2019
2 parents 05c7a00 + 16715c5 commit a7edd91
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
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

0 comments on commit a7edd91

Please sign in to comment.