mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-14 17:41:45 +04:00
feat: Adds just_warn option to allow commit when return value is not zero
This commit is contained in:
parent
b74a22d96c
commit
6f0b860928
3 changed files with 10 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -4,3 +4,5 @@
|
|||
/.tox
|
||||
/dist
|
||||
.vscode/
|
||||
.venv
|
||||
build
|
||||
|
|
@ -292,15 +292,19 @@ def _run_hooks(
|
|||
)
|
||||
retval = 0
|
||||
prior_diff = _get_diff()
|
||||
just_warn = False
|
||||
for hook in hooks:
|
||||
current_retval, prior_diff = _run_single_hook(
|
||||
classifier, hook, skips, cols, prior_diff,
|
||||
verbose=args.verbose, use_color=args.color,
|
||||
)
|
||||
retval |= current_retval
|
||||
if current_retval and (config['fail_fast'] or hook.fail_fast):
|
||||
if not hook.just_warn:
|
||||
retval |= current_retval
|
||||
else:
|
||||
just_warn |= current_retval
|
||||
if (current_retval or just_warn) and (config['fail_fast'] or hook.fail_fast):
|
||||
break
|
||||
if retval and args.show_diff_on_failure and prior_diff:
|
||||
if (retval or just_warn) and args.show_diff_on_failure and prior_diff:
|
||||
if args.all_files:
|
||||
output.write_line(
|
||||
'pre-commit hook(s) made changes.\n'
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class Hook(NamedTuple):
|
|||
require_serial: bool
|
||||
stages: Sequence[str]
|
||||
verbose: bool
|
||||
just_warn: bool
|
||||
|
||||
@property
|
||||
def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue