mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
Add fail-fast argument for run command
This commit is contained in:
parent
e70b313c80
commit
c78f248c60
5 changed files with 22 additions and 1 deletions
|
|
@ -106,6 +106,7 @@ def _ns(
|
|||
hook=None,
|
||||
verbose=False,
|
||||
show_diff_on_failure=False,
|
||||
fail_fast=False,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -298,7 +298,8 @@ def _run_hooks(
|
|||
verbose=args.verbose, use_color=args.color,
|
||||
)
|
||||
retval |= current_retval
|
||||
if current_retval and (config['fail_fast'] or hook.fail_fast):
|
||||
fail_fast = (config['fail_fast'] or hook.fail_fast or args.fail_fast)
|
||||
if current_retval and fail_fast:
|
||||
break
|
||||
if retval and args.show_diff_on_failure and prior_diff:
|
||||
if args.all_files:
|
||||
|
|
|
|||
|
|
@ -76,6 +76,10 @@ def _add_run_options(parser: argparse.ArgumentParser) -> None:
|
|||
'--show-diff-on-failure', action='store_true',
|
||||
help='When hooks fail, run `git diff` directly afterward.',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--fail-fast', action='store_true',
|
||||
help='Stop after the first failing hook.',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--hook-stage',
|
||||
choices=clientlib.STAGES,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue