-
Notifications
You must be signed in to change notification settings - Fork 210
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
Shared hooks #155
Comments
Wrting the code you wish you had...: pre-commit:
parallel: true
commands:
...
scripts:
"terraform_tfsec.sh "
...
repos:
their-tfm:
vendor: git
repo: git:https://github.com/antonbabenko/pre-commit-terraform
This would populate a folder mkdir .lefthook-shared
git sub-repo clone git:https://github.com/antonbabenko/pre-commit-terraform ./.lefthook-shared/their-tfm Note that Of course the above is PoC and the pre-commit repo scripts are not expected to work out the box. |
This would be nice. But I think we can also start porting pre_commit_hooks to Go and add to Lefthook. This would make using Lefthook nicer. https://github.com/pre-commit/pre-commit-hooks/tree/master/pre_commit_hooks |
Exactly why I found this issue. Don't really want to define our hook scripts in multiple repos and have to maintain that across repos. I couldn't find a way to do that with lefthook, am I missing something? |
Any idea if this is ever going to happen? |
Adding a repo of scripts for lefthook and referring it from the config might be helpful. I would really appreciate if you could provide the way you see it. Any use case example would be helpful. |
I think the OP's example is pretty much exactly the same as my use case. I've used (and currently use pre-commit) to run hooks across many repos. Reference terraform pre-commit hooks in my config so they aren't defined per repo, just configured per repo. |
@mrexox I was looking into leveraging this functionality recently and came across this issue. I've opened up #323 with an implementation of this functionality. I've attempted to keep Lefthook as fast as possible when processing remote configs, so all git processing is done within a goroutine. I hope to contribute this feature to the project as I'm a big fan, and appreciate all feedback! 😄 |
The proposed config solution for repos sound really cool. In the meantime I ended up with a different solution for sharing hooks. I publish an npm package containing the shared hooks (e.g. Example source_dir: "./node_modules/lefthook-shared/lefthook"
pre-commit:
scripts:
"script.sh":
runner: bash |
Whoa! This is a really cool hack! 💯 BTW I hope to finish the PR with remote hooks support and release it with 1.2.0 in about 2 weeks |
Thank you for the effort you have put into lefthook and for making it opensource.
It would be useful to be able to share hooks.
since Pre-Commit already does this, consuming their convention would immediately provide a resource of hooks?
Or not, that doesn't matter.
The important idea is being able to share hooks - I suggest also looking at the git sub-repo as a way to manage shared repositories.
Pre-commit Example:
The text was updated successfully, but these errors were encountered: