You don't need any tooling to create hooks. We have agreed on a simple convention. Your project is shipped with a git_hooks
folder which has the same directory structure like the git hooks
folder. In this way we can create symbol links and make them versionable with git.
If you create a new git hook file you have to excute the command again.
- Create a folder
$GIT_DIR/git_hooks
in the root directory of your template. - Create a git hook specific file in
git_hooks
e.g$GIT_DIR/git_hooks/pre-commit
. - Run Butler and execute
Create Git Hooks
command.
pre-commit
#!/bin/sh
echo "hook executed!"
Git Hooks are installed automatically when a new project template is created.
Node.js
#!/usr/bin/env node
console.log("hook executed!")
Python
#!/usr/bin/python
print "hook executed!"
Powershell
powershell -ExecutionPolicy RemoteSigned -Command .\.git_hooks\scripts\build.ps1
Hooks are programs you can place in the $GIT_DIR/git_hooks
directory to
trigger actions at certain points in git's execution.
Before Git invokes a hook, it changes its working directory to either the root of the working tree in a non-bare repository, or to the $GIT_DIR in a bare repository.
Hooks can get their arguments via the environment, command-line arguments, and stdin. See the documentation for each hook below for details.
The currently supported hooks are described here.