question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Sep 3, 2020

the reason for that if you dig in: pre-commit/pre-commit-hooks#315 pre-commit/pre-commit-hooks#361

0reactions
rpdelaneycommented, Sep 3, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found