File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -216,14 +216,14 @@ def warn_unknown_keys_repo(
216216 (
217217 'check-hooks-apply' , (
218218 ('name' , 'Check hooks apply to the repository' ),
219- ('files' , C .CONFIG_FILE ),
219+ ('files' , f'^ { re . escape ( C .CONFIG_FILE ) } $' ),
220220 ('entry' , _entry ('check_hooks_apply' )),
221221 ),
222222 ),
223223 (
224224 'check-useless-excludes' , (
225225 ('name' , 'Check for useless excludes' ),
226- ('files' , C .CONFIG_FILE ),
226+ ('files' , f'^ { re . escape ( C .CONFIG_FILE ) } $' ),
227227 ('entry' , _entry ('check_useless_excludes' )),
228228 ),
229229 ),
Original file line number Diff line number Diff line change 11import logging
2+ import re
23
34import cfgv
45import pytest
1011from pre_commit .clientlib import CONFIG_SCHEMA
1112from pre_commit .clientlib import DEFAULT_LANGUAGE_VERSION
1213from pre_commit .clientlib import MANIFEST_SCHEMA
14+ from pre_commit .clientlib import META_HOOK_DICT
1315from pre_commit .clientlib import MigrateShaToRev
1416from pre_commit .clientlib import validate_config_main
1517from pre_commit .clientlib import validate_manifest_main
@@ -392,6 +394,15 @@ def test_meta_hook_invalid(config_repo):
392394 cfgv .validate (config_repo , CONFIG_REPO_DICT )
393395
394396
397+ def test_meta_check_hooks_apply_only_at_top_level ():
398+ cfg = {'id' : 'check-hooks-apply' }
399+ cfg = cfgv .apply_defaults (cfg , META_HOOK_DICT )
400+
401+ files_re = re .compile (cfg ['files' ])
402+ assert files_re .search ('.pre-commit-config.yaml' )
403+ assert not files_re .search ('foo/.pre-commit-config.yaml' )
404+
405+
395406@pytest .mark .parametrize (
396407 'mapping' ,
397408 (
You can’t perform that action at this time.
0 commit comments