Implement quiet mode, silent on skipped hooks

This commit is contained in:
Peter Cock 2020-08-15 13:54:57 +01:00
parent f1de792877
commit 89d88f7ebc
2 changed files with 27 additions and 19 deletions

View file

@ -137,35 +137,38 @@ def _run_single_hook(
diff_before: bytes,
verbose: bool,
use_color: bool,
quiet: bool,
) -> Tuple[bool, bytes]:
filenames = classifier.filenames_for_hook(hook)
if hook.id in skips or hook.alias in skips:
output.write(
_full_msg(
start=hook.name,
end_msg=SKIPPED,
end_color=color.YELLOW,
use_color=use_color,
cols=cols,
),
)
if not quiet:
output.write(
_full_msg(
start=hook.name,
end_msg=SKIPPED,
end_color=color.YELLOW,
use_color=use_color,
cols=cols,
),
)
duration = None
retcode = 0
diff_after = diff_before
files_modified = False
out = b''
elif not filenames and not hook.always_run:
output.write(
_full_msg(
start=hook.name,
postfix=NO_FILES,
end_msg=SKIPPED,
end_color=color.TURQUOISE,
use_color=use_color,
cols=cols,
),
)
if not quiet:
output.write(
_full_msg(
start=hook.name,
postfix=NO_FILES,
end_msg=SKIPPED,
end_color=color.TURQUOISE,
use_color=use_color,
cols=cols,
),
)
duration = None
retcode = 0
diff_after = diff_before
@ -272,6 +275,7 @@ def _run_hooks(
current_retval, prior_diff = _run_single_hook(
classifier, hook, skips, cols, prior_diff,
verbose=args.verbose, use_color=args.color,
quiet=False if args.verbose else args.quiet,
)
retval |= current_retval
if retval and config['fail_fast']: