Place this to .git/hooks/commit-msg
in project root to append issue number from branch name to commit message.
Created
October 7, 2014 23:57
-
-
Save dmitryn/2e882a871ff19f8ce1c4 to your computer and use it in GitHub Desktop.
GH issue number appender
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
#!/bin/sh | |
# Adds github issue number to commit message based on current branch name. | |
# Example: current branch '308-context-help', commit message 'fix bug', | |
# final commit message will be '#308 fix bug' | |
if [ "$NOPREFIX" ]; then | |
exit 0 | |
fi | |
number=$(git branch | grep '*' | sed 's/* //' | cut -d'-' -f 1) | |
if [[ "$number" =~ ^[0-9]+$ ]] ; then | |
echo 'OBSLabs/virool#'"$number"' '$(cat "$1") > "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment