Skip to content

Commit d05bccd

Browse files
authored
Merge pull request #105 from pre-commit-ci/skip_aliases
fix: Allow skipping aliased hooks
2 parents d7b98fe + aa8c93b commit d05bccd

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

pre_commit_ci_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ def _check_autoupdate_branch(val: str) -> None:
2525
class ValidateSkip:
2626
def check(self, dct: dict[str, Any]) -> None:
2727
all_ids = {
28-
hook['id']
28+
hook_id
2929
for repo in dct['repos']
3030
for hook in repo['hooks']
31+
for hook_id in (hook['id'], hook.get('alias'))
32+
if hook_id is not None
3133
}
3234
unexpected_skip = set(dct.get('ci', {}).get('skip', ())) - all_ids
3335
if unexpected_skip:

tests/pre_commit_ci_config_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@ def test_skip_referencing_missing_hook():
9494
)
9595

9696

97+
def test_skip_references_hook_with_alias():
98+
cfg = {
99+
'ci': {'skip': ['alternate-identity']},
100+
'repos': [
101+
{
102+
'repo': 'meta',
103+
'hooks': [
104+
{
105+
'id': 'identity',
106+
'alias': 'alternate-identity',
107+
},
108+
],
109+
},
110+
],
111+
}
112+
cfgv.validate(cfg, SCHEMA)
113+
114+
97115
def test_main_ok(tmpdir):
98116
cfg_s = '''\
99117
ci:

0 commit comments

Comments
 (0)