LoginSignup
4
4

More than 5 years have passed since last update.

Commitメッセージにブランチ名からissue番号を取得して追加するスクリプト

Last updated at Posted at 2014-09-14

学生のおかげでgithubのprivateリポジトリを2年無料で使えるので
こそこそissue作ってコミットにIDを振ったりして開発をしているんですが

よくIDを振り忘れるのでhookを書きました。

インストール

動作確認: OS X

$ curl https://gist.githubusercontent.com/k2wanko/2217a7615b776a29d544/raw/prepare-commit-msg > .git/hooks/prepare-commit-msg && chmod +x .git/hooks/prepare-commit-msg

できること

$ git branch
* add-notify#123
  master
$ git commit # -m オプションなし
refs #123 <- が先頭にに追加された状態でエディタが開く

$ git commit -m "Add README"
[add-notify#123 a123] Add README #123 <- 追加される
...

$ git commit -m "Add README #321" <- コミットメッセージに自分でIDを入れとく場合
[add-notify#123 a123] Add README #321 <- 追加されない

使えるブランチ名

issue idは123と仮定
branchnameは "add-(´・ω・`)" や "fix-( ・`ω・´)" などの任意の文字列

  • branchname#123
  • branchname-123
  • branchname_123
  • issue123
  • issues123
  • issue/123
  • issues/123
  • branchname/issue/123
  • branchname/issues/123
  • 123_branchname
  • 123-branchname
  • #123branchname

参考

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4