diff options
author | Igor Wiedler <igor@wiedler.ch> | 2010-03-08 00:41:42 +0100 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2010-03-08 00:41:42 +0100 |
commit | d0d1ab54710f7a7f3426b2bcdfd63e9df24c046e (patch) | |
tree | 71dc7304df8eb1a7259c155cb302c975e23f3a6e /git-tools/hooks/prepare-commit-msg | |
parent | ac329275662f737f03f485107cb69412739c1afa (diff) | |
download | forums-d0d1ab54710f7a7f3426b2bcdfd63e9df24c046e.tar forums-d0d1ab54710f7a7f3426b2bcdfd63e9df24c046e.tar.gz forums-d0d1ab54710f7a7f3426b2bcdfd63e9df24c046e.tar.bz2 forums-d0d1ab54710f7a7f3426b2bcdfd63e9df24c046e.tar.xz forums-d0d1ab54710f7a7f3426b2bcdfd63e9df24c046e.zip |
Adding a branchname prepare-commit-msg hook
Git supports several hooks, some of which are client-side. The
prepare-commit-msg hook is run right after a `git commit` call, before
the editor is opened. This allows the initial message to be altered.
This hook will check if the current branch name begins with `bug/`, in
which case it will prepend `[$branchname]` to the commit message. This
makes it easier to create proper commit messages.
http://wiki.phpbb.com/Git#Commit_Messages
For more information refer to the hook source.
Diffstat (limited to 'git-tools/hooks/prepare-commit-msg')
-rwxr-xr-x | git-tools/hooks/prepare-commit-msg | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/git-tools/hooks/prepare-commit-msg b/git-tools/hooks/prepare-commit-msg new file mode 100755 index 0000000000..284354081e --- /dev/null +++ b/git-tools/hooks/prepare-commit-msg @@ -0,0 +1,24 @@ +#!/bin/sh +# +# A hook to add [$branch] to the beginning of a commit message +# if certain conditions are met. +# +# This is a prepare-commit-msg hook. +# +# To install this you can either copy or symlink it to +# $GIT_DIR/hooks, example: +# +# ln -s ../../git-tools/hooks/prepare-commit-msg \\ +# .git/hooks/prepare-commit-msg +# +# Make sure it is executable. + +# strip off ref: refs/heads/ +branch="$(cat $GIT_DIR/HEAD | sed 's/ref: refs\/heads\///g')" + +# * only run when normal commit is made (without -m or -F; +# not a merge, etc.) +# * also make sure the branch name begins with bug/ +if [ "$2" = "" ] && [ $(echo "$branch" | grep -e '^bug/') ]; then + echo "[$branch] $(cat $1)" > "$1" +fi |