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

Skip to content

Commit 3d7b374

Browse files
committed
Pass correct value to git color based on args.color
1 parent 64f0178 commit 3d7b374

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

pre_commit/commands/run.py

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

232234
return retval

tests/commands/run_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,20 @@ def test_global_exclude(cap_out, store, tempdir_factory):
184184
(
185185
{
186186
'show_diff_on_failure': True,
187-
'color': 'auto',
187+
},
188+
b'All changes made by hooks:',
189+
),
190+
(
191+
{
192+
'show_diff_on_failure': True,
193+
'color': True,
188194
},
189195
b'All changes made by hooks:',
190196
),
191197
(
192198
{
193199
'show_diff_on_failure': True,
194200
'all_files': True,
195-
'color': 'auto',
196201
},
197202
b'reproduce locally with: pre-commit run --all-files',
198203
),

0 commit comments

Comments
 (0)