-
Notifications
You must be signed in to change notification settings - Fork 220
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
Custom hook folder #839
Comments
Hey! Could you please provide more details about the suggested setting? Git uses only one dir for hooks, so if you have And if you have lefthook hook installed in |
Hello, thank you for your reply
Here is the scenario The So if i do a What i m trying to do is install lefthook just for That way I can still use global hooks that will be executed on ALL repos precommit and also execute lefthook on This is why i would like that have this option that way lefthook never override my global/pre-commit script. Hope this make sense |
Similar yes - but the total opposite. If I understand correctly you want to execute common scripts in all your repos via lefthook. I, on the other hand, want to only invoke lefthook in ONE repo without overriding my global git hook folder (which currently does a lot of other things that lefthook is totally overriding as it takes over the system) |
Sorry for a delay. Let me clarify your use case.
I guess you can't implicitly make Git execute two scripts on a git hook. You can only run one pre-commit script, either global (from global If you want to use lefthook together with your hooks without lefthook overriding your hooks you can configure git config --local core.hooksPath .git/hooks/ And if you want to run both global and local hooks I can suggest you something like this: # lefthook
pre-commit:
jobs:
- name: run global hook
run: sh ~/hooks/pre-commit {0} # pass the same arguments
- name: run local hook command
run: yarn lint
- name: run local hook command 2
run: yarn test |
Hi Valentin Using Unfortunately our company global ~/githooks/pre-commit does other things globally as well as calling each repo custom pre-commit hooks (like security scanning) etc Furthermore lefthook only provides This is why having that custom-hook folder install option would be greatly appreciated Thank you |
Oh, I guess I understand. You have global hooks configured and the local hooks also set up in a specific folder, and the global hook calls the local hook. In this case I can suggest you the following. Manually create a hook script (e.g. #!/bin/sh
lefthook run pre-commit --no-auto-install "$@" This will execute the pre-commit hook and avoid installing the scripts to Also I'd like to mention that lefthook supports all hooks Git supports 😉 Please, share your thoughts on whether this workaround works for you or not. I'd like to avoid adding specific git hooks setting just because it's more about git's responsibility, not lefthook's. |
Yes this is essentially what I ended up doing, So instead i used Works so far but wanted to simplify this and also enjoy the "auto update" of those template if necessary thus my ask for this lefthook configuration
Anyway I appreciate your patience, please feel free to close this issue if you do not think it is a good candidate for lefthook (I did my best to try to prove otherwise :) ) Thank you |
Thank you for providing all the context. I think if this feature finds more requests and more cases I'll add it to lefthook. I'm closing the issue, but for anyone needing this feature: please, describe your case and if there's no workaround, I'll consider adding custom hooks path. |
⚡ Summary
Right now lefthook automatically installs github hooks files in the
git rev-parse --git-path hooks
folderThis folder should be configurable.
Value
Every systems is configured differently,
A common scenario is to setup a global hook folder that contains all the github hooks that will delegate to other scripts stored in different directories.
A use case would be to have script executed on all your repositories installed on your computer but also add custom hooks at each repos level
e.g
~/.gitconfig
~/.hooks/pre-commit hooks that execute global scripts + delegate to individual repo pre-commit hooks if needed
~/repo1/.hooks/pre-commit
~/repo2/.hooks/pre-commit
Behavior and configuration changes
Add a new configuration at the root level
use that directory when installing and synchronizing hooks scripts
e.g if you are in
~/repo1
.lefthook install
will add git hooks scripts to~/repo1/.hooks
If
hooks_folder
is not provided fallback togit rev-parse --git-path hooks
The text was updated successfully, but these errors were encountered: