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

Skip to content

Commit c148845

Browse files
author
Michael Adkins
committed
Added hook-stage print to output for missing hook id
1 parent 927b2ab commit c148845

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

pre_commit/commands/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def run(config_file, store, args, environ=os.environ):
285285
]
286286

287287
if args.hook and not hooks:
288-
output.write_line('No hook with id `{}`'.format(args.hook))
288+
output.write_line('No hook with id `{}` in stage `{}`'.format(args.hook, args.hook_stage))
289289
return 1
290290

291291
install_hook_envs(hooks, store)

tests/commands/run_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,13 @@ def test_show_diff_on_failure(
231231
({}, (b'Bash hook', b'Passed'), 0, True),
232232
({'verbose': True}, (b'foo.py\nHello World',), 0, True),
233233
({'hook': 'bash_hook'}, (b'Bash hook', b'Passed'), 0, True),
234-
({'hook': 'nope'}, (b'No hook with id `nope`',), 1, True),
234+
({'hook': 'nope'}, (b'No hook with id `nope` in stage `commit`',), 1, True),
235+
(
236+
{'hook': 'nope', 'hook_stage': 'push'},
237+
(b'No hook with id `nope` in stage `push`',),
238+
1,
239+
True
240+
),
235241
(
236242
{'all_files': True, 'verbose': True},
237243
(b'foo.py',),

0 commit comments

Comments
 (0)