This is inspired by ghooks-org/ghooks. It is also a proof of concept for a possible new major version of the javascript library.
- Add this to your application's
shard.yml
:
development_dependencies:
ghooks.cr:
github: gtramontina/ghooks.cr
version: <version>
NOTE: It is not advised to install ghooks.cr
as a production dependency as it will install git hooks in your production environment as well. Please install it under the development_dependencies
section of your shard.yml
.
- Run
shards install
; - Then place all your git hooks under the
.githooks/
directory. Make sure they are executable, as per the documentation;
This shard is actually just a makefile
that does the following:
- Backs up the existing
.git/hooks/
directory to.git/hooks.bkp/
; - Creates a symbolic link between
.git/hooks/
and.githooks/
;
That's essentially it. A couple of benefits I see over the original javascript implementation are, at this point:
- Does not abstract the execution of the hooks too much (makes it closer to how git actually works);
- Different branches can have a set of different hooks; this is not much of a problem with the original implementation, though;
- I've been using this approach with makefiles and a directory to host the git hooks for non-javascript projects for a while and I'm quite satisfied with the usage;
- NOTE: still have to figure out how this would work on Windows, given we're relying on symlinks.
This software is licensed under the MIT license