diff --git a/tools/git-hooks/prepare-commit-msg b/tools/git-hooks/prepare-commit-msg index 13bbe84a72..23d6f18195 100755 --- a/tools/git-hooks/prepare-commit-msg +++ b/tools/git-hooks/prepare-commit-msg @@ -1,6 +1,7 @@ #!/bin/sh BRANCH=`git branch | grep '^\*' | cut -b3-` +ISSUE=`git branch | grep -o '^\* [0-9]*' | cut -b3-` if test "$BRANCH" == "master"; then echo "ERROR: You are on branch $BRANCH" @@ -9,7 +10,11 @@ if test "$BRANCH" == "master"; then exit 1 fi -BRANCH_NUMBER=`git branch | grep -o '^\* [0-9]*' | cut -b3-` -/bin/echo -n "[#$BRANCH_NUMBER] " > "$1.msg" +if [ -n "$ISSUE" ]; then + /bin/echo -n "[#$ISSUE] " > "$1.msg" +else + /bin/echo -n "[$BRANCH] " > "$1.msg" +fi + cat "$1" >> "$1.msg" mv "$1.msg" "$1"