Skip to content

Commit

Permalink
Merge pull request #2480 from imc-trading/fix-skip-alias
Browse files Browse the repository at this point in the history
respect aliases in SKIP when installing environments
  • Loading branch information
asottile committed Aug 11, 2022
2 parents 49f95b9 + 587c6b9 commit 6740a17
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pre_commit/commands/run.py
Expand Up @@ -420,7 +420,11 @@ def run(
return 1

skips = _get_skips(environ)
to_install = [hook for hook in hooks if hook.id not in skips]
to_install = [
hook
for hook in hooks
if hook.id not in skips and hook.alias not in skips
]
install_hook_envs(to_install, store)

return _run_hooks(config, hooks, skips, args)
Expand Down
26 changes: 26 additions & 0 deletions tests/commands/run_test.py
Expand Up @@ -635,6 +635,32 @@ def test_skip_bypasses_installation(cap_out, store, repo_with_passing_hook):
assert ret == 0


def test_skip_alias_bypasses_installation(
cap_out, store, repo_with_passing_hook,
):
config = {
'repo': 'local',
'hooks': [
{
'id': 'skipme',
'name': 'skipme-1',
'alias': 'skipme-1',
'entry': 'skipme',
'language': 'python',
'additional_dependencies': ['/pre-commit-does-not-exist'],
},
],
}
add_config_to_repo(repo_with_passing_hook, config)

ret, printed = _do_run(
cap_out, store, repo_with_passing_hook,
run_opts(all_files=True),
{'SKIP': 'skipme-1'},
)
assert ret == 0


def test_hook_id_not_in_non_verbose_output(
cap_out, store, repo_with_passing_hook,
):
Expand Down

0 comments on commit 6740a17

Please sign in to comment.