Created
May 21, 2013 21:02
-
-
Save Newky/5623229 to your computer and use it in GitHub Desktop.
Write-up for blog post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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