Pass color option to git diff (on failure)

Fixes #1007
This commit is contained in:
Mandar Vaze
2019-05-31 16:42:16 +05:30
parent 0b6a39768a
commit 4f4767c9e0
2 changed files with 15 additions and 1 deletions

View File

@@ -224,7 +224,14 @@ def _run_hooks(config, hooks, args, environ):
'`pre-commit install`.',
)
output.write_line('All changes made by hooks:')
subprocess.call(('git', '--no-pager', 'diff', '--no-ext-diff'))
if args.color:
subprocess.call((
'git', '--no-pager', 'diff', '--no-ext-diff',
'--color={}'.format(args.color),
))
else:
subprocess.call(('git', '--no-pager', 'diff', '--no-ext-diff'))
return retval

View File

@@ -187,6 +187,13 @@ def test_global_exclude(cap_out, store, tempdir_factory):
},
b'All changes made by hooks:',
),
(
{
'show_diff_on_failure': True,
'color': 'auto',
},
b'All changes made by hooks:',
),
(
{
'show_diff_on_failure': True,