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

Hooks that have stages: set in .pre-commit-hooks.yaml do not respect caller's default_stages setting #515

Closed
rpdelaney opened this issue Sep 3, 2020 · 5 comments
Labels

Comments

@rpdelaney
Copy link
Contributor

rpdelaney commented Sep 3, 2020

I just added my first pre-push hook as an experiment. For now, I want to run that hook when pushing, but not all the others. So I set default_stages: [commit] in my .pre-commit-config.yaml.

Here's what I see on push:

$ git push
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
Check that executables have shebangs.................(no files to check)Skipped
run all tests............................................................Passed

I expected only that last one, but instead I got the first three as well.

In this repository it looks like these are the only hooks that have their own stages setting. I'd venture a guess that that setting is somehow over-riding the default_stages setting in a caller's config.

@asottile
Copy link
Member

asottile commented Sep 3, 2020

yep this is working as intended

(optional: default (all stages)) a configuration-wide default for the stages property of hooks. This will only override individual hooks that do not set stages.

@rpdelaney
Copy link
Contributor Author

Hrm. Is there another way I could prevent these hooks from running on push?

@asottile
Copy link
Member

asottile commented Sep 3, 2020

override their stages property

@rpdelaney
Copy link
Contributor Author

Ok. Just to be clear, I don't think there's any problem with how pre-commit is handling this -- but it is a bit of a surprise that when adding hooks from this repo, these three of them are unaffected by the default_stages setting and require an explicit over-ride, while the others don't. Not any kind of big deal though, of course. Thanks

@asottile
Copy link
Member

asottile commented Sep 3, 2020

the reason for that if you dig in: #315 #361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants