Skip to content

Instantly share code, notes, and snippets.

@co3k
Created October 6, 2009 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save co3k/202866 to your computer and use it in GitHub Desktop.
Save co3k/202866 to your computer and use it in GitHub Desktop.
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