mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 01:51:46 +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
|
/.tox
|
||||||
/dist
|
/dist
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.venv
|
||||||
|
build
|
||||||
|
|
@ -292,15 +292,19 @@ def _run_hooks(
|
||||||
)
|
)
|
||||||
retval = 0
|
retval = 0
|
||||||
prior_diff = _get_diff()
|
prior_diff = _get_diff()
|
||||||
|
just_warn = False
|
||||||
for hook in hooks:
|
for hook in hooks:
|
||||||
current_retval, prior_diff = _run_single_hook(
|
current_retval, prior_diff = _run_single_hook(
|
||||||
classifier, hook, skips, cols, prior_diff,
|
classifier, hook, skips, cols, prior_diff,
|
||||||
verbose=args.verbose, use_color=args.color,
|
verbose=args.verbose, use_color=args.color,
|
||||||
)
|
)
|
||||||
retval |= current_retval
|
if not hook.just_warn:
|
||||||
if current_retval and (config['fail_fast'] or hook.fail_fast):
|
retval |= current_retval
|
||||||
|
else:
|
||||||
|
just_warn |= current_retval
|
||||||
|
if (current_retval or just_warn) and (config['fail_fast'] or hook.fail_fast):
|
||||||
break
|
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:
|
if args.all_files:
|
||||||
output.write_line(
|
output.write_line(
|
||||||
'pre-commit hook(s) made changes.\n'
|
'pre-commit hook(s) made changes.\n'
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class Hook(NamedTuple):
|
||||||
require_serial: bool
|
require_serial: bool
|
||||||
stages: Sequence[str]
|
stages: Sequence[str]
|
||||||
verbose: bool
|
verbose: bool
|
||||||
|
just_warn: bool
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
|
def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue