Skip to content

Instantly share code, notes, and snippets.

@Newky
Created May 21, 2013 21:02
Show Gist options
  • Save Newky/5623229 to your computer and use it in GitHub Desktop.
Save Newky/5623229 to your computer and use it in GitHub Desktop.
Write-up for blog post.
$ hooked.py --help
Usage: hooked.py [options]
Options:
-h, --help show this help message and exit
--git-root=GITROOT the root directory of the git folder to inject hook
--clean Clean up after yourself
$ # lets make a new repo
$ mkdir hooked-test
$ cd hooked-test
$ git init
$ hooked.py --git-root=$HOME/hooked-test
$ # the hooks are now installed
$ # non standard hooks are listed
$ ls .git/hooks/ | grep -v sample
action
pre-commit
prepare-commit-msg
$ ls .git/hooks/action
config.json __init__.py other_hook.py test_hook.py
$ cat .git/hooks/action/test_hook.py
def precommit(git_state):
print git_state["files"]
return True
def preparecommitmsg(git_state):
with open(git_state["commit_file_path"], "r") as commit:
print commit.read()
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment