Hooks that have `stages:` set in .pre-commit-hooks.yaml do not respect caller's `default_stages` setting
See original GitHub issueI 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Supported hooks - pre-commit
github.com/pre-commit/pre-commit-hooks. check-added-large-files - prevents giant files from being committed. check-ast - simply checks whether the files ...
Read more >Git pre-commit hooks in .yaml file can't push to github
I'm trying to create an R function that automatically creates git commit hooks in the file .pre-commit-config.yaml if it isn't already ...
Read more >Pre-commit hooks you must know - Towards Data Science
pre-commit hooks are a mechanism of the version control system git. They let you execute code right before the commit. Confusingly, there is...
Read more >refs/tags/v4.1.0 - pre-commit-hooks - Git at Google
Both master and main are protected by default if no branch argument is set. -b / --branch may be specified multiple times to...
Read more >githooks Documentation - Git
Hooks that don't have the executable bit set are ignored. By default the hooks directory is $GIT_DIR/hooks , but that can be changed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the reason for that if you dig in: pre-commit/pre-commit-hooks#315 pre-commit/pre-commit-hooks#361
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 thedefault_stages
setting and require an explicit over-ride, while the others don’t. Not any kind of big deal though, of course. Thanks