8000 fix per-hook fail_fast to not fail on previous failures · pre-commit/pre-commit@fc62215 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc62215

Browse files
committed
fix per-hook fail_fast to not fail on previous failures
1 parent 716da1e commit fc62215

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pre_commit/commands/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _run_hooks(
298298
verbose=args.verbose, use_color=args.color,
299299
)
300300
retval |= current_retval
301-
if retval and (config['fail_fast'] or hook.fail_fast):
301+
if current_retval and (config['fail_fast'] or hook.fail_fast):
302302
break
303303
if retval and args.show_diff_on_failure and prior_diff:
304304
if args.all_files:

tests/commands/run_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,22 @@ def test_fail_fast_per_hook(cap_out, store, repo_with_failing_hook):
10881088
assert printed.count(b'Failing hook') == 1
10891089

10901090

1091+
def test_fail_fast_not_prev_failures(cap_out, store, repo_with_failing_hook):
1092+
with modify_config() as config:
1093+
config['repos'].append({
1094+
'repo': 'meta',
1095+
'hooks': [
1096+
{'id': 'identity', 'fail_fast': True},
1097+
{'id': 'identity', 'name': 'run me!'},
1098+
],
1099+
})
1100+
stage_a_file()
1101+
1102+
ret, printed = _do_run(cap_out, store, repo_with_failing_hook, run_opts())
1103+
# should still run the last hook since the `fail_fast` one didn't fail
1104+
assert printed.count(b'run me!') == 1
1105+
1106+
10911107
def test_classifier_removes_dne():
10921108
classifier = Classifier(('this_file_does_not_exist',))
10931109
assert classifier.filenames == []

0 commit comments

Comments
 (0)
0