diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index 33c0f10b..b858af4b 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -285,7 +285,7 @@ def run(config_file, store, args, environ=os.environ): ] if args.hook and not hooks: - output.write_line('No hook with id `{}`'.format(args.hook)) + output.write_line('No hook with id `{}` in stage `{}`'.format(args.hook, args.hook_stage)) return 1 install_hook_envs(hooks, store) diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py index fc2a973c..d2938234 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -231,7 +231,13 @@ def test_show_diff_on_failure( ({}, (b'Bash hook', b'Passed'), 0, True), ({'verbose': True}, (b'foo.py\nHello World',), 0, True), ({'hook': 'bash_hook'}, (b'Bash hook', b'Passed'), 0, True), - ({'hook': 'nope'}, (b'No hook with id `nope`',), 1, True), + ({'hook': 'nope'}, (b'No hook with id `nope` in stage `commit`',), 1, True), + ( + {'hook': 'nope', 'hook_stage': 'push'}, + (b'No hook with id `nope` in stage `push`',), + 1, + True + ), ( {'all_files': True, 'verbose': True}, (b'foo.py',),