Merge pull request #695 from bagerard/Verbose_hook

Add a verbose hook option
This commit is contained in:
Anthony Sottile
2018-02-01 08:19:08 -08:00
committed by GitHub
4 changed files with 23 additions and 1 deletions

View File

@@ -68,6 +68,7 @@ MANIFEST_HOOK_DICT = schema.Map(
schema.Optional('log_file', schema.check_string, ''),
schema.Optional('minimum_pre_commit_version', schema.check_string, '0'),
schema.Optional('stages', schema.check_array(schema.check_string), []),
schema.Optional('verbose', schema.check_bool, False),
)
MANIFEST_SCHEMA = schema.Array(MANIFEST_HOOK_DICT)

View File

@@ -130,7 +130,10 @@ def _run_single_hook(filenames, hook, repo, args, skips, cols):
output.write_line(color.format_color(pass_fail, print_color, args.color))
if (stdout or stderr or file_modifications) and (retcode or args.verbose):
if (
(stdout or stderr or file_modifications) and
(retcode or args.verbose or hook['verbose'])
):
output.write_line('hookid: {}\n'.format(hook['id']))
# Print a message if failing due to file modifications

View File

@@ -292,6 +292,23 @@ def test_always_run_alt_config(
)
def test_hook_verbose_enabled(
cap_out, repo_with_passing_hook, mock_out_store_directory,
):
with modify_config() as config:
config['repos'][0]['hooks'][0]['always_run'] = True
config['repos'][0]['hooks'][0]['verbose'] = True
_test_run(
cap_out,
repo_with_passing_hook,
{},
(b'Hello World',),
0,
stage=False,
)
@pytest.mark.parametrize(
('origin', 'source', 'expect_failure'),
(

View File

@@ -789,4 +789,5 @@ def test_manifest_hooks(tempdir_factory, store):
'stages': [],
'types': ['file'],
'exclude_types': [],
'verbose': False,
}