Merge pull request #695 from bagerard/Verbose_hook · precommit/pre-commit@17444cd · GitHub
Skip to content

Commit 17444cd

Browse files
authored
Merge pull request pre-commit#695 from bagerard/Verbose_hook
Add a verbose hook option
2 parents 7f0b427 + b319d6f commit 17444cd

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

pre_commit/clientlib.py

Lines changed: 1 addition & 0 deletions

pre_commit/commands/run.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ def _run_single_hook(filenames, hook, repo, args, skips, cols):
130130

131131
output.write_line(color.format_color(pass_fail, print_color, args.color))
132132

133-
if (stdout or stderr or file_modifications) and (retcode or args.verbose):
133+
if (
134+
(stdout or stderr or file_modifications) and
135+
(retcode or args.verbose or hook['verbose'])
136+
):
134137
output.write_line('hookid: {}\n'.format(hook['id']))
135138

136139
# Print a message if failing due to file modifications

tests/commands/run_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,23 @@ def test_always_run_alt_config(
292292
)
293293

294294

295+
def test_hook_verbose_enabled(
296+
cap_out, repo_with_passing_hook, mock_out_store_directory,
297+
):
298+
with modify_config() as config:
299+
config['repos'][0]['hooks'][0]['always_run'] = True
300+
config['repos'][0]['hooks'][0]['verbose'] = True
301+
302+
_test_run(
303+
cap_out,
304+
repo_with_passing_hook,
305+
{},
306+
(b'Hello World',),
307+
0,
308+
stage=False,
309+
)
310+
311+
295312
@pytest.mark.parametrize(
296313
('origin', 'source', 'expect_failure'),
297314
(

tests/repository_test.py

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)