Last active
August 29, 2015 14:22
-
-
Save ivalkeen/66568b4cba5e1c4129ce to your computer and use it in GitHub Desktop.
Git hooks
This file contains hidden or 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
#! /bin/zsh | |
# if git branch name contains number, add leading [#NNN] to the commit message | |
# so github will add reference to specific issue | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
BRANCH_NUMBER=$(git symbolic-ref --short HEAD | sed "s/[^0-9]//g") | |
COMMIT_TEXT=$(cat $1) | |
if [ -n "$BRANCH_NUMBER" ] && ! [[ $COMMIT_TEXT =~ "\[.*#$BRANCH_NUMBER\]" ]]; then | |
sed -i.bak -e "1s/^/[#$BRANCH_NUMBER] /" $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment