diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index d060e186..33c0f10b 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -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 diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py index b465cae6..fc2a973c 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -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,