Meathook
Meathook is a gem to help manage a living set of githooks. Inspired by Babar (http://github.com/jdabbs/babar), but intended to be more general in purpose.
.hooks
The .hooks.yaml
file should be committed in the root of your repository -
it's a yaml file like so:
---
path: "bin/meathook"
pre-commit:
no_focus:
command: "git diff --cached spec/ | grep '^+' | grep ':focus'"
condition: "nonempty"
halt: true
message: "You are trying to commit a focused spec!"
post-merge:
remember_to_bundle:
command: "git diff --name-only HEAD^..HEAD | grep Gemfile
condition: "nonempty"
halt: false
message: "Gemfile was just updated - remember to run 'bundle install'"
Each hook type can be a toplevel key in that file, and the keys in each are arbitrary names of tasks. Each task then has the keys:
- command: command to run - output and exit code can both be relevant
- condition: one of [nonempty, empty, failed, successful]
- halt: under those conditions, should we halt the procedure? (commit, merge, etc)
- message: message to show the user if the condition is true
The 'path' key is special, and is used to supply a literal path to the meathook script,
so that your githooks don't have to use bundler (which can add a half-second onto each
operation). if which meathook
doesn't give you a path, then you need to specify a path
with this key.
meathook install
In order to run the githooks, meathook needs to install a self-call into each of the
.git/hooks scripts of the form meathook execute <hookname>
.
meathook uninstall
Removes the meathook call from all of the githooks.