There was an error while loading. Please reload this page.
language: fail
1 parent 21c2c9d commit ce25b65Copy full SHA for ce25b65
2 files changed
pre_commit/meta_hooks/check_hooks_apply.py
@@ -15,7 +15,7 @@ def check_all_hooks_match_files(config_file):
15
16
for repo in repositories(load_config(config_file), Store()):
17
for hook_id, hook in repo.hooks:
18
- if hook['always_run']:
+ if hook['always_run'] or hook['language'] == 'fail':
19
continue
20
include, exclude = hook['files'], hook['exclude']
21
filtered = _filter_by_include_exclude(files, include, exclude)
tests/meta_hooks/check_hooks_apply_test.py
@@ -106,7 +106,7 @@ def test_hook_types_excludes_everything(
106
assert 'check-useless-excludes does not apply to this repository' in out
107
108
109
-def test_valid_includes(capsys, tempdir_factory, mock_store_dir):
+def test_valid_always_run(capsys, tempdir_factory, mock_store_dir):
110
config = {
111
'repos': [
112
{
@@ -131,3 +131,32 @@ def test_valid_includes(capsys, tempdir_factory, mock_store_dir):
131
132
out, _ = capsys.readouterr()
133
assert out == ''
134
+
135
136
+def test_valid_language_fail(capsys, tempdir_factory, mock_store_dir):
137
+ config = {
138
+ 'repos': [
139
+ {
140
+ 'repo': 'local',
141
+ 'hooks': [
142
+ # Should not be reported as an error due to language: fail
143
144
+ 'id': 'changelogs-rst',
145
+ 'name': 'changelogs must be rst',
146
+ 'entry': 'changelog filenames must end in .rst',
147
+ 'language': 'fail',
148
+ 'files': r'changelog/.*(?<!\.rst)$',
149
+ },
150
+ ],
151
152
153
+ }
154
155
+ repo = git_dir(tempdir_factory)
156
+ add_config_to_repo(repo, config)
157
158
+ with cwd(repo):
159
+ assert check_hooks_apply.main(()) == 0
160
161
+ out, _ = capsys.readouterr()
162
+ assert out == ''
0 commit comments