mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 13:00:10 -06:00
make repo: meta only apply to top level configuration
This commit is contained in:
@@ -216,14 +216,14 @@ _meta = (
|
||||
(
|
||||
'check-hooks-apply', (
|
||||
('name', 'Check hooks apply to the repository'),
|
||||
('files', C.CONFIG_FILE),
|
||||
('files', f'^{re.escape(C.CONFIG_FILE)}$'),
|
||||
('entry', _entry('check_hooks_apply')),
|
||||
),
|
||||
),
|
||||
(
|
||||
'check-useless-excludes', (
|
||||
('name', 'Check for useless excludes'),
|
||||
('files', C.CONFIG_FILE),
|
||||
('files', f'^{re.escape(C.CONFIG_FILE)}$'),
|
||||
('entry', _entry('check_useless_excludes')),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import re
|
||||
|
||||
import cfgv
|
||||
import pytest
|
||||
@@ -10,6 +11,7 @@ from pre_commit.clientlib import CONFIG_REPO_DICT
|
||||
from pre_commit.clientlib import CONFIG_SCHEMA
|
||||
from pre_commit.clientlib import DEFAULT_LANGUAGE_VERSION
|
||||
from pre_commit.clientlib import MANIFEST_SCHEMA
|
||||
from pre_commit.clientlib import META_HOOK_DICT
|
||||
from pre_commit.clientlib import MigrateShaToRev
|
||||
from pre_commit.clientlib import validate_config_main
|
||||
from pre_commit.clientlib import validate_manifest_main
|
||||
@@ -392,6 +394,15 @@ def test_meta_hook_invalid(config_repo):
|
||||
cfgv.validate(config_repo, CONFIG_REPO_DICT)
|
||||
|
||||
|
||||
def test_meta_check_hooks_apply_only_at_top_level():
|
||||
cfg = {'id': 'check-hooks-apply'}
|
||||
cfg = cfgv.apply_defaults(cfg, META_HOOK_DICT)
|
||||
|
||||
files_re = re.compile(cfg['files'])
|
||||
assert files_re.search('.pre-commit-config.yaml')
|
||||
assert not files_re.search('foo/.pre-commit-config.yaml')
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'mapping',
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user