-
-
Save keitakn/4a5e687496825fd81e3095d872e4bc7b to your computer and use it in GitHub Desktop.
my prepare-commit-msg
This file contains hidden or 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/bash | |
| # このshを任意の場所に配置して、core.hooksPathに設定すると全体で利用できます。 | |
| # e.g. /usr/local/etc/git-hooks/ にこのスクリプトを配置した場合 | |
| # git config --global core.hooksPath /usr/local/etc/git-hooks/ | |
| out=$1 | |
| cat $out | |
| function message() { | |
| mv $out $out.tmp | |
| cat <<EOS > $out | |
| $1#`git branch | grep "issue*" | awk '{print $2}' | grep -o -e '[0-9]\+'` | |
| EOS | |
| cat $out.tmp >> $out | |
| } | |
| str=$(cat <<-EOS | |
| 🐛 :bug: バグ修正 | |
| 🔥 :fire: ファイル・機能の削除 | |
| ✨ :sparkles: 機能追加 | |
| ♻️ :recycle: リファクタリング | |
| ✏️ :pencil2: typo | |
| 🎨 :art: 構造の変更 | |
| 📝;:memo: READMEなどdocs更新 | |
| 💚 :green_heart: テストやCIの修正・改善 | |
| ✅ :white_check_mark: テスト追加時 | |
| 👕 :shirt: Lintエラーの修正やコードスタイルの修正 | |
| 🔧 :wrench: 設定ファイルの修正、環境変数の追加・修正 | |
| ⬆️ :arrow_up: 依存パッケージのupgrade | |
| ⬇️ :arrow_down: 依存パッケージのdowngrade | |
| ➖ :heavy_minus_sign: 依存パッケージの削除 | |
| ➕ :heavy_plus_sign: 依存パッケージ追加 | |
| 🚧 :construction: WIP | |
| 🚀 :rocket: パフォーマンス改善 | |
| 🙈 :see_no_evil: .gitignoreのadd/update | |
| 🐭 :mouse: add/update .editorconfig | |
| 🎉 :tada: Initial Commit | |
| EOS | |
| ) | |
| type=$(echo "$str" | peco | awk 'match($0, /(:.*:)/) {print substr($0, RSTART, RLENGTH)}') | |
| message "$type " |
Author
Author
配置したスクリプトには実行権限を与えておく必要がある。
chmod 755 /usr/local/etc/git-hooks/prepare-commit-msg
Author
最近はhooksPathを ~/git-hooks/ にしている。
git config --global core.hooksPath ~/git-hooks/
[core]
hooksPath = ~/git-hooks/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
下記のインストールが必要
https://github.com/peco/peco