Last active
June 23, 2016 18:40
-
-
Save yogsototh/0f0fae6c1f9c6e2afbbb6e467d9e07a0 to your computer and use it in GitHub Desktop.
enforce commit message to start with issue number
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/bash | |
# | |
# This file should be in .git/hooks/commit-msg | |
# It uses the current branch name to prefix the commit message. | |
name=$(git rev-parse --abbrev-ref HEAD | sed 's/\(issue-[0-9]*\).*/\1/') | |
if [ $name != 'HEAD' ]; then | |
cat $1 | sed "s/^$name: //" | egrep -v "^#" > $1.tmp | |
echo -n "$name"': ' > $1 | |
cat $1.tmp >> $1 | |
rm $1.tmp | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you're welcome! I've updated it again since there was a bug with multiline comments.