Skip to content

Commit ae5b74a

Browse files
committed
always_run hooks always apply to the repository
1 parent 6a177c4 commit ae5b74a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pre_commit/meta_hooks/check_hooks_apply.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def check_all_hooks_match_files(config_file):
1414

1515
for repo in runner.repositories:
1616
for hook_id, hook in repo.hooks:
17+
if hook['always_run']:
18+
continue
1719
include, exclude = hook['files'], hook['exclude']
1820
filtered = _filter_by_include_exclude(files, include, exclude)
1921
types, exclude_types = hook['types'], hook['exclude_types']

tests/meta_hooks/check_hooks_apply_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ def test_valid_includes(
116116
OrderedDict((
117117
('id', 'check-useless-excludes'),
118118
)),
119+
# Should not be reported as an error due to always_run
120+
OrderedDict((
121+
('id', 'check-useless-excludes'),
122+
('files', '^$'),
123+
('always_run', True),
124+
)),
119125
),
120126
),
121127
))

0 commit comments

Comments
 (0)