追記: 実際使ってみたら上手く動作しなかったため、調べ直して使用するhookを変更しました。Qiitaでも既出のネタでしたね
ここにPivotal Trackerのstoryがあるじゃろ?
これの末尾の「stories/123456789」の部分だけ抜き出すと、
$ git checkout -b stories/123456789
user storyに対応したbranchができるじゃろ?
これを↓の .git/hooks/prepare-commit-msg
と組み合わせて
.git/hooks/prepare-commit-msg
# !/bin/bash
story_id=$(git rev-parse --abbrev-ref HEAD | sed -n 's#.*stories/\([0-9]\+\).*#\1#p')
story_url=https://www.pivotaltracker.com/story/show/$story_id
if [ -n "$story_id" ] && ! grep --quiet -e $story_url $1 ; then
echo >> $1
echo user story: $story_url >> $1
fi
$ chmod +x .git/hooks/prepare-commit-msg
いつもどおりgit commit
すれば、
user storyへのURL付きコミットメッセージの出来上がりじゃ。
参考
【Github時代のgit hook】issue番号を勝手にcommit commentに入れてくれるやつ - Qiita
How to get current branch name in Git? - Stack Overflow