From c148845a984851973f7de535420b9645f0963e95 Mon Sep 17 00:00:00 2001 From: Michael Adkins Date: Tue, 9 Jul 2019 13:06:18 -0500 Subject: [PATCH 1/2] Added hook-stage print to output for missing hook id --- pre_commit/commands/run.py | 2 +- tests/commands/run_test.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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',), From 02d95c033cf2736b164412007695947644b83839 Mon Sep 17 00:00:00 2001 From: Michael Adkins Date: Tue, 9 Jul 2019 13:48:06 -0500 Subject: [PATCH 2/2] Fixed code style --- pre_commit/commands/run.py | 6 +++++- tests/commands/run_test.py | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index b858af4b..4087a650 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -285,7 +285,11 @@ def run(config_file, store, args, environ=os.environ): ] if args.hook and not hooks: - output.write_line('No hook with id `{}` in stage `{}`'.format(args.hook, args.hook_stage)) + 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 d2938234..94d44e15 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -231,12 +231,17 @@ 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` in stage `commit`',), 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 + True, ), ( {'all_files': True, 'verbose': True},