-
Notifications
You must be signed in to change notification settings - Fork 279
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
Support unversioned/local hooks #527
Comments
Actually, maybe the above makes more sense as a kind of global configuration setting. But anyway, that's one idea. :) |
I figured out a way to do this. I added a bunch of hook definitions like this: PostCheckout:
Local:
enabled: true
required_executable: ".git-hooks/local/post-checkout"
PostCommit:
Local:
enabled: true
required_executable: ".git-hooks/local/post-commit" Then I check those files into version control. They look like e.g.: #!/usr/bin/env bash
if [[ -f .local-git-hooks/post-checkout ]]; then
exec .local-git-hooks/post-checkout $*
fi Then, I can optionally create hooks in |
Thanks for sharing, @harto. This is a great workaround. On small point: careful with the use of #!/usr/bin/env bash
if [[ -f .local-git-hooks/post-checkout ]]; then
exec .local-git-hooks/post-checkout "$@"
fi Yes, the double quotes are important as well. Consider the following two scripts: for arg in "$@"; do echo $arg; done for arg in $@; do echo $arg; done Running
Hope this helps! |
Oh, nice. Thanks for the bash tip! (I always forget how to quote things properly...) |
I was wondering if there's a generalized way to run hooks that are specific to my development environment. For example, I'd like a post-checkout hook that calls
ctags
with a specific configuration, but many engineers on my team don't usectags
.One thought I had was to implement a hook that could be configured to look for unversioned hooks in a specified directory. I.e. maybe something like:
Then if
<repo>/.unversioned-git-hooks
containedpost-checkout
, etc. they would be run after regular Overcommit hooks. And/.unversioned-git-hooks
could be added to.gitignore
.The text was updated successfully, but these errors were encountered: