Skip to content

Commit 587c6b9

Browse files
committed
respect aliases in SKIP when installing environments
1 parent 49f95b9 commit 587c6b9

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

pre_commit/commands/run.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,11 @@ def run(
420420
return 1
421421

422422
skips = _get_skips(environ)
423-
to_install = [hook for hook in hooks if hook.id not in skips]
423+
to_install = [
424+
hook
425+
for hook in hooks
426+
if hook.id not in skips and hook.alias not in skips
427+
]
424428
install_hook_envs(to_install, store)
425429

426430
return _run_hooks(config, hooks, skips, args)

tests/commands/run_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,32 @@ def test_skip_bypasses_installation(cap_out, store, repo_with_passing_hook):
635635
assert ret == 0
636636

637637

638+
def test_skip_alias_bypasses_installation(
639+
cap_out, store, repo_with_passing_hook,
640+
):
641+
config = {
642+
'repo': 'local',
643+
'hooks': [
644+
{
645+
'id': 'skipme',
646+
'name': 'skipme-1',
647+
'alias': 'skipme-1',
648+
'entry': 'skipme',
649+
'language': 'python',
650+
'additional_dependencies': ['/pre-commit-does-not-exist'],
651+
},
652+
],
653+
}
654+
add_config_to_repo(repo_with_passing_hook, config)
655+
656+
ret, printed = _do_run(
657+
cap_out, store, repo_with_passing_hook,
658+
run_opts(all_files=True),
659+
{'SKIP': 'skipme-1'},
660+
)
661+
assert ret == 0
662+
663+
638664
def test_hook_id_not_in_non_verbose_output(
639665
cap_out, store, repo_with_passing_hook,
640666
):

0 commit comments

Comments
 (0)