Merge pull request #1051 from mandarvaze/master

Pass color option to git diff (on failure)
This commit is contained in:
Anthony Sottile 2019-06-01 08:11:45 -07:00 committed by GitHub
commit a75fe69984
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -224,7 +224,13 @@ 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'))
# args.color is a boolean.
# See user_color function in color.py
subprocess.call((
'git', '--no-pager', 'diff', '--no-ext-diff',
'--color={}'.format({True: 'always', False: 'never'}[args.color]),
))
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': True,
},
b'All changes made by hooks:',
),
(
{
'show_diff_on_failure': True,