Skip to content

Instantly share code, notes, and snippets.

@co3k co3k/commit-msg
Created Oct 6, 2009

Embed
What would you like to do?
git コミット時にチケット番号の記述を強制する奴
#!/bin/sh
if grep "\(refs\|fixes\) #[0-9]\+" $1 > /dev/null; then
ticket=$(sed -e "s/.*\(fixes\|refs\) #\([0-9]\+\).*/\2/" .git/COMMIT_EDITMSG | line)
title=$(curl -s "http://redmine.openpne.jp/issues/$ticket" | sed -n "/<title>/p" | sed "s/<title>\(.\+\)<\/title>/\1/")
if [ "404 - OpenPNE Issue Tracking System" = "$title" ]; then
echo "The specified ticket #$ticket is undefined."
exit 1
fi
echo "This commit will be related to:"
if [ "" != "$title" ]; then
echo $title
else
echo "#$ticket"
fi
exit 0
else
echo "This commit isn't related to any tickets."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.