diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index a58e2747..33c0f10b 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -224,9 +224,11 @@ def _run_hooks(config, hooks, args, environ): '`pre-commit install`.', ) output.write_line('All changes made by hooks:') + # args.color is a boolean. + # See user_color function in color.py subprocess.call(( 'git', '--no-pager', 'diff', '--no-ext-diff', - '--color={}'.format(args.color), + '--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 a6266fac..fc2a973c 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -184,7 +184,13 @@ def test_global_exclude(cap_out, store, tempdir_factory): ( { 'show_diff_on_failure': True, - 'color': 'auto', + }, + b'All changes made by hooks:', + ), + ( + { + 'show_diff_on_failure': True, + 'color': True, }, b'All changes made by hooks:', ), @@ -192,7 +198,6 @@ def test_global_exclude(cap_out, store, tempdir_factory): { 'show_diff_on_failure': True, 'all_files': True, - 'color': 'auto', }, b'reproduce locally with: pre-commit run --all-files', ),