mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
pre_commit: expose fail-fast argument for run subcommand
This patch exposes the fail-fast feature as a command-line argument for the run subcommand, allowing to run pre-commit to stop at the first failed hook without the need of temporarily writing it to the configuration file when temporarily needed. Signed-off-by: Luís Ferreira <contact@lsferreira.net>
This commit is contained in:
parent
d021bbfabd
commit
61efc539a4
5 changed files with 23 additions and 2 deletions
|
|
@ -973,7 +973,7 @@ def test_pass_filenames(
|
|||
assert (b'foo.py' in printed) == pass_filenames
|
||||
|
||||
|
||||
def test_fail_fast(cap_out, store, repo_with_failing_hook):
|
||||
def test_fail_fast_config(cap_out, store, repo_with_failing_hook):
|
||||
with modify_config() as config:
|
||||
# More than one hook
|
||||
config['fail_fast'] = True
|
||||
|
|
@ -985,6 +985,19 @@ def test_fail_fast(cap_out, store, repo_with_failing_hook):
|
|||
assert printed.count(b'Failing hook') == 1
|
||||
|
||||
|
||||
def test_fail_fast_args(cap_out, store, repo_with_failing_hook):
|
||||
with modify_config() as config:
|
||||
# More than one hook
|
||||
config['repos'][0]['hooks'] *= 2
|
||||
stage_a_file()
|
||||
|
||||
ret, printed = _do_run(
|
||||
cap_out, store, repo_with_failing_hook, run_opts(fail_fast=True),
|
||||
)
|
||||
# it should have only run one hook
|
||||
assert printed.count(b'Failing hook') == 1
|
||||
|
||||
|
||||
def test_classifier_removes_dne():
|
||||
classifier = Classifier(('this_file_does_not_exist',))
|
||||
assert classifier.filenames == []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue