Skip to content

Commit

Permalink
Merge pull request #43 from blueyed/fix-diff-with-mnemonicprefix-2
Browse files Browse the repository at this point in the history
Fix git-diff with `mnemonicprefix` option
  • Loading branch information
Bachmann1234 committed Feb 13, 2016
2 parents a9bf53e + f68bef9 commit 3b6f471
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions diff_cover/git_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def diff_committed(self, compare_branch='origin/master'):
to stderr.
"""
return execute([
'git', 'diff',
'git', '-c', 'diff.mnemonicprefix=no', 'diff',
"{branch}...HEAD".format(branch=compare_branch),
'--no-color',
'--no-ext-diff'
Expand All @@ -41,7 +41,8 @@ def diff_unstaged(self):
Raises a `GitDiffError` if `git diff` outputs anything
to stderr.
"""
return execute(['git', 'diff', '--no-color', '--no-ext-diff'])[0]
return execute(['git', '-c', 'diff.mnemonicprefix=no', 'diff',
'--no-color', '--no-ext-diff'])[0]

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

# Expect that the correct command was executed
expected = ['git', 'diff', 'origin/master...HEAD', '--no-color', '--no-ext-diff']
expected = ['git', '-c', 'diff.mnemonicprefix=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 @@ -39,7 +40,8 @@ def test_diff_unstaged(self):
self.assertEqual(output, 'test output')

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

# Expect that the correct command was executed
expected = ['git', 'diff', '--cached', '--no-color', '--no-ext-diff']
expected = ['git', '-c', 'diff.mnemonicprefix=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 @@ -67,7 +70,8 @@ def test_diff_committed_compare_branch(self):
self.assertEqual(output, 'test output')

# Expect that the correct command was executed
expected = ['git', 'diff', 'release...HEAD', '--no-color', '--no-ext-diff']
expected = ['git', '-c', 'diff.mnemonicprefix=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
2 changes: 1 addition & 1 deletion diff_cover/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _set_git_diff_output(self, stdout, stderr):
a phony directory.
"""
def patch_diff(command, **kwargs):
if command[0:2] == ['git', 'diff']:
if command[0:4] == ['git', '-c', 'diff.mnemonicprefix=no', 'diff']:
mock = Mock()
mock.communicate.return_value = (stdout, stderr)
return mock
Expand Down

0 comments on commit 3b6f471

Please sign in to comment.