SuperHooks is a quick way to have hooks apply across multiple projects. It allows you to decouple the hooks you use from the projects you use them in by pacing the hooks into separate folders.
Hooks are defined at three levels:
- Global hooks : hooks available everywhere
- User hooks : hooks used for your own user
- Project hooks : hooks used only for a project
Once a hook gets invoked from
git, all the different types of hook will run.
brew tap frankywahl/brew email@example.com:frankywahl/homebrew-brew.git brew install --HEAD frankywahl/brew/super_hooks
Installation from source
You will need
Go to install it yourself from source
$ make install
super_hooks into a git repository:
$ super_hooks install
List the current hooks:
$ super_hooks list
See the other options with:
$ super_hooks help
|User Hooks||indicated by your
|Project Hooks||indicated by your
|Global Hooks||indicated by your
The way most people work is to have a single folder with all hooks for them.
$ `git config --global hooks.global `pwd``
Note: You can have multiple
hooks.global configurations by either:
1. adding them with the command: `git config --add hooks.global </path/to/hooks/directory>` 2. adding the paths in a comma separated value way
super_hooks is installed, you can easily create hooks by placing executables files (
chmod 755) under a folder with the hook name.
For example, if you were to create a pre-commit hook for your user, you would do the following:
$ mkdir -p ~/.git_hooks/pre-commit/ $ git config hooks.user ~/.git_hooks $ touch ~/.git_hooks/pre-commit/cool_hook $ chmod 755 ~/.git_hooks/pre-commit/cool_hook
Note: having a
--about option when running your executable will allow you to have a short description when listing hooks. See my rake example for this project.
Example: I have my own hooks which I have installed for all of my projects:
$ git clone firstname.lastname@example.org:frankywahl/git_hooks.git somewhere $ cd somewhere $ git config --global hooks.global `pwd`
- Fork it ( https://github.com/[my-github-username]/super_hooks/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request
Copyright (c) 2017 Franky W.
See LICENSE.txt for details.