Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85aa1c4

Browse files
committed
Merge pull request #177 from pre-commit/staged_files_only_176
Fix staged_files_only for color.diff always. Closes #176.
2 parents b2cb0f6 + 0479f78 commit 85aa1c4

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

pre_commit/staged_files_only.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ def staged_files_only(cmd_runner):
2121
"""
2222
# Determine if there are unstaged files
2323
retcode, diff_stdout_binary, _ = cmd_runner.run(
24-
['git', 'diff', '--ignore-submodules', '--binary', '--exit-code'],
24+
[
25+
'git', 'diff', '--ignore-submodules', '--binary', '--exit-code',
26+
'--no-color',
27+
],
2528
retcode=None,
2629
encoding=None,
2730
)

tests/staged_files_only_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def test_foo_something_unstaged(foo_staged, cmd_runner):
7070
_test_foo_state(foo_staged, 'herp\nderp\n', 'AM')
7171

7272

73+
def test_foo_something_unstaged_diff_color_always(foo_staged, cmd_runner):
74+
cmd_output('git', 'config', '--local', 'color.diff', 'always')
75+
test_foo_something_unstaged(foo_staged, cmd_runner)
76+
77+
7378
def test_foo_both_modify_non_conflicting(foo_staged, cmd_runner):
7479
with io.open(foo_staged.foo_filename, 'w') as foo_file:
7580
foo_file.write(FOO_CONTENTS + '9\n')

0 commit comments

Comments
 (0)