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.

Automatically apply changes and retry or only run if previous hooks succeeded

See original GitHub issue

Hi,

First of all thanks for the awesome framework. Pre-commit is great 👏

I often find myself running pre-commit by adding my changes with git add and then committing. Then, typically it will “fail” because just one or two lines will be fixed by one of the hooks (typically black), and I will re-run the git commands once more to finish committing my changes.

This doesn’t take much effort, but running everything twice it is a pattern I repeat almost every time I commit something: Would you ever consider adding an option to automatically re-committing the changes made by individual hooks? As in, say you could specify in the config that if black makes changes, pre-commit should simply add those changes to the staged diff, before running the hook once more, and then running the remaining hooks?

To prevent the xy problem: the underlying reason why running pre-commit twice can sometimes be inconvenient in the first place, is because we have several static checkers like flake8 and mypy which we don’t really want to run until all code changes are out of the way. Our mypy hook in particular can take up to 10-15 seconds to run, and as a consequence I will usually interrupt pre-commit after the first few hooks have run (if one “failed”) and re-run all commands.

Finally, I recognise that there might be good reasons why this doesn’t make sense; that pre-commit could be built in a way where it’s not worth a complete restructuring to implement such a feature; or that perhaps my workflow is just sub-optimal, so this is primarily a question over a feature request 🙂

Thanks!

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
asottilecommented, Feb 25, 2021

yes that’s the fail_fast option

0reactions
sondrelgcommented, Feb 25, 2021

Thanks 👏👏👏👏

EDIT: I guess what I was after was a hook-level fail-fast option, but I discovered a new setting I didn’t know about that solves the same issue: I’ve specified mypy to run on push instead of commit 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

React hook that retries an operation until it succeeds
Our useEffect hook will fire whenever isResolved changes. isResolved is a boolean that initializes as false , and only changes when our callback ......
Read more >
AppSpec 'hooks' section - AWS CodeDeploy
The 'hooks' section for a Lambda or an Amazon ECS deployment specifies Lambda validation functions to run during a deployment lifecycle event.
Read more >
Resource Hooks - Declarative GitOps CD for Kubernetes
Hooks are simply Kubernetes manifests tracked in the source repository of your Argo CD Application annotated with argocd.argoproj.io/hook , e.g.:.
Read more >
Merge when pipeline succeeds - GitLab Docs
If the pipeline succeeds, the merge request is merged. If the pipeline fails, the author can either retry any failed jobs, or push...
Read more >
Replay failed Zap runs - Zapier Help
Replaying a Zap run only retries failed steps, not successful steps. ... the same even if data from previous steps changes after replay....
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