hookz
Manages commit hooks inside a local git repository based on a configuration.
Configuration
Hookz uses a configuration file to generate hooks in your local git repository. This file needs to be in the root of your repository and must be named .hooks.yaml
Take for example the following configuration:
hooks:
- name: "PlantUML Image Generator"
type: pre-commit
url: https://github.com/jjimenez/pre-plantuml
args: [deflate]
- name: "Post-Commit Echo"
type: post-commit
exec: derp
args: ["Hello World"]
Hooks will read this configuration and create a pre-commit hook and a post-commit hook based on this yaml.
The pre-commit will download the binary from the defined URL and configure the pre-commit to execute the command with the defined arguments before a commit happens.
The post-commit in this configuration will execute a command named "derp" with the arguments "Hello World" after a commit has occurred. Note that the derp command must be on your path. If it isn't this post-commit will fail because the command isn't found.
Return Codes
Any non-zero return code from a command executed in a hook will return a FAIL.
Running Hookz
To generate the hooks as defined in your configuration simply execute the following:
hookz init
Removing hooks can be done by executing the following command:
hookz remove
Example Hooks
Pull from your remote branch before committing
- name: "Git Pre-Commit Pull"
type: pre-commit
exec: git
args: [pull]
TODO
- Create a verbose flag that doesn't eat command error messages
- Allow for multiple type actions
- Download binary from URL and make executable in the .git/hooks directory