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

Skip to content

Commit 95afd64

Browse files
authored
Merge pull request #1079 from madkinsz/run-stage-prompt-1078
Added hook-stage print to output for missing hook id
2 parents 927b2ab + 02d95c0 commit 95afd64

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

pre_commit/commands/run.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ 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(
289+
'No hook with id `{}` in stage `{}`'.format(
290+
args.hook, args.hook_stage,
291+
),
292+
)
289293
return 1
290294

291295
install_hook_envs(hooks, store)

tests/commands/run_test.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,18 @@ 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+
(
235+
{'hook': 'nope'},
236+
(b'No hook with id `nope` in stage `commit`',),
237+
1,
238+
True,
239+
),
240+
(
241+
{'hook': 'nope', 'hook_stage': 'push'},
242+
(b'No hook with id `nope` in stage `push`',),
243+
1,
244+
True,
245+
),
235246
(
236247
{'all_files': True, 'verbose': True},
237248
(b'foo.py',),

0 commit comments

Comments
 (0)