Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect aliases SKIP when installing environments #2479

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
17 changes: 16 additions & 1 deletion tests/commands/run_test.py
Expand Up @@ -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)
Expand All @@ -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
Comment on lines 644 to +650
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test now validates two separate things -- it should be two separate tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just future open source advice, don't make PRs from your main branch as it makes it significantly more difficult to review / fix

Sure. I was in the gerrit workflow mindset.

I can put it in a separate test method.

I see the CI failing, should I rebase on v2.20.0 or is this fine?



def test_hook_id_not_in_non_verbose_output(
cap_out, store, repo_with_passing_hook,
Expand Down