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

Skip to content

Commit a75fe69

Browse files
authored
Merge pull request #1051 from mandarvaze/master
Pass color option to git diff (on failure)
2 parents fff3ad5 + 3d7b374 commit a75fe69

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

pre_commit/commands/run.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,13 @@ def _run_hooks(config, hooks, args, environ):
224224
'`pre-commit install`.',
225225
)
226226
output.write_line('All changes made by hooks:')
227-
subprocess.call(('git', '--no-pager', 'diff', '--no-ext-diff'))
227+
# args.color is a boolean.
228+
# See user_color function in color.py
229+
subprocess.call((
230+
'git', '--no-pager', 'diff', '--no-ext-diff',
231+
'--color={}'.format({True: 'always', False: 'never'}[args.color]),
232+
))
233+
228234
return retval
229235

230236

tests/commands/run_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ def test_global_exclude(cap_out, store, tempdir_factory):
187187
},
188188
b'All changes made by hooks:',
189189
),
190+
(
191+
{
192+
'show_diff_on_failure': True,
193+
'color': True,
194+
},
195+
b'All changes made by hooks:',
196+
),
190197
(
191198
{
192199
'show_diff_on_failure': True,

0 commit comments

Comments
 (0)