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

Allow skipping pre-push on certain branches #354

Closed
Brcrwilliams opened this issue Nov 7, 2022 · 4 comments · Fixed by #376
Closed

Allow skipping pre-push on certain branches #354

Brcrwilliams opened this issue Nov 7, 2022 · 4 comments · Fixed by #376
Labels
feature request A new lefthook feature description

Comments

@Brcrwilliams
Copy link

Brcrwilliams commented Nov 7, 2022

Summary

I work for GitLab. We have a rather elaborate pre-push configuration for lefthook, and we install lefthook automatically via the GitLab Development Kit.
Something we have noticed as of late is that community contributors are confused by lefthook running (and often failing)
when they try to sync their forks with the upstream repository (meaning, they rebase master on upstream and then push to remote master on their fork). I would like to be able to add a configuration to pre-push hooks so that they can be skipped when on a certain branch (master in this case).

Value

Since we install Lefthook automatically, contributors aren't very aware of what it is when they first encounter it. They may not realize that it is a git hook, or that it can be bypassed using --no-verify. Being able to skip lefthook on master would get rid of a lot of friction for these people.

Behavior and configuration changes

I'd like to add a top-level configuration option onto pre-push that can be given a branch or ref, and will cause lefthook to skip all commands when on that ref.

pre-push:
  skip:
    - ref: master # When on master, skips both `a` and `b`
  commands:
    a:
      run: echo a
    b:
      run: echo b
@Brcrwilliams Brcrwilliams added the feature request A new lefthook feature description label Nov 7, 2022
@mrexox
Copy link
Member

mrexox commented Nov 7, 2022

Hey @Brcrwilliams thank you for the issue! I hope to get to it as soon as possible and put it in a next release. 2 weeks at most. Don't hesitate to ping me :)

@mrexox
Copy link
Member

mrexox commented Nov 22, 2022

Hey! I've prepared a PR with the feature you described. Please, take a look if you can (you can also test it if you want). I am going to merge the PR tomorrow and maybe release it with a 1.2.2 version this week. I hope, everything works just as you expected :)

@mrexox
Copy link
Member

mrexox commented Nov 23, 2022

Hey! Check out v1.2.2 version. The feature must be there :)

@Brcrwilliams
Copy link
Author

This is great @mrexox 🙏 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants