From 19ca2077aa3a30ff950c1434063ae7ce61fe8196 Mon Sep 17 00:00:00 2001 From: Mark Korondi Date: Wed, 10 Aug 2022 17:04:05 +0200 Subject: [PATCH] respect aliases SKIP when installing environments --- pre_commit/commands/run.py | 6 +++++- tests/commands/run_test.py | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index ad3d766ef..8d11882c0 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -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) diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py index 2634c0c5e..ec858bd27 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -618,11 +618,19 @@ def test_skip_bypasses_installation(cap_out, store, repo_with_passing_hook): 'hooks': [ { 'id': 'skipme', - 'name': 'skipme', + 'name': 'skipme-1', 'entry': 'skipme', + 'alias': 'skipme-1', 'language': 'python', 'additional_dependencies': ['/pre-commit-does-not-exist'], }, + { + 'id': 'skipme', + 'name': 'skipme-2', + 'entry': 'skipme', + 'alias': 'skipme-2', + 'language': 'python', + }, ], } add_config_to_repo(repo_with_passing_hook, config) @@ -634,6 +642,13 @@ def test_skip_bypasses_installation(cap_out, store, repo_with_passing_hook): ) assert ret == 0 + ret, printed = _do_run( + cap_out, store, repo_with_passing_hook, + run_opts(all_files=True), + {'SKIP': 'skipme-1'}, + ) + assert ret == 1 + def test_hook_id_not_in_non_verbose_output( cap_out, store, repo_with_passing_hook,