Created
March 27, 2013 14:09
-
-
Save kyanro/5254422 to your computer and use it in GitHub Desktop.
windows版 SourceTreeのコミットログに自動でブランチ名とかチケット番号を入れる方法 ref: http://qiita.com/items/d7a0f01236f90339516a
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 | |
#ブランチ名を取得 もっといい方法あるかも。 | |
Branch="$(git branch | grep "*" | awk '{print $2}')" | |
if [ $Branch == "master" ] ; then | |
#masterでのコミットは別ルールにしたかったのでとりあえず分けてみた | |
ReqestNo="" | |
CommitBranch="master" | |
else | |
#正規表現でブランチ名からとチケット番号と、コミット番号抜きのブランチ名を取得 | |
ReqestNo="$(echo $Branch | sed -e "s/^.*-\([0-9]\+\)$/\1/g")" | |
CommitBranch="$(echo $Branch | sed -e "s/^\(.*\)-[0-9]\+$/\1/g")" | |
fi | |
#コミットメッセージの最初にチケット番号を、最後にコミット番号抜きのブランチ名を追加 | |
mv $1 $1.tmpbycommit-msg | |
echo -n "[#$ReqestNo] " > $1 | |
cat $1.tmpbycommit-msg >> $1 | |
echo "*$CommitBranch" >> $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.git/hooks/commit-msg
example)
branch name
hotfix-9999
add commit message
[#9999]
and*hotfix