これは
緩くしたくて、原理主義者を騙したいコミットのヤーツ を書くのである
<発生効果>
* commit 粒度、内容が限定されて運用が楽に
* PullRequestのレビュワーも理解しやく
* 履歴も綺麗に
* 絵文字でエモく
機能
- commit メッセージのテンプレ化
-
git commit
するとテンプレ内容を出力
-
- commit メッセージの置換
- commit type に対応したもののEmojiに変換
- commit 形式のゆるいチェック
- commit type に対応する・しないをチェック
Commit Format
<commit type>: <description>
or <commit type>(optional<scope>): <description>
ご利用上の注意
-
git commit —amend
の時は先頭Emojiを消して下さい - 複数行のEmojiも再置換するので、消して下さい
Install
1、git-conventinal-or-semantic-comits::gist からファイルをダウンロードしてください
- commit-msg
- commit-template (好きに編集してください)
- gen.py (カスタマイズしたい場合)
詳細はこちら gist Install
# commit msg check and replace to emoji
cp commit-msg .git/hooks
# set commit template
git config commit.template <path to template>/commit-template
お試し
$ echo "feat: add new func
fix: fix bug
refactor: change structure
docs: write api docs
test: add test case
style: css update
perf: increase
build: modify env variable
release: ship it ver111
snipet: add simple shell
security: modify holl
feat(mod): add feature with scope
fix(mod): fix bug with scope
test(mod): update test case with scope" > msg.txt
$ bash commit-msg msg.txt
✊ feat: add new func
🔥 fix: fix bug
🌈 refactor: change structure
📚 docs: write api docs
💊 test: add test case
⭐ style: css update
🏁 perf: increase
🐳 build: modify env variable
🚀 release: ship it ver111
🍄 snipet: add simple shell
🔐 security: modify holl
✊ feat(mod): add feature with scope
🔥 fix(mod): fix bug with scope
💊 test(mod): update test case with scope
俺用にカスタマイズしたい方は
gen.py を編集して python gen.py
を実行してください
emoji={'feat':'\\xE2\\x9C\\x8A',
:
'snipet': '\\xF0\\x9F\\x8D\\x84',
'security': '\\xF0\\x9F\\x94\\x90' # emoji は自由に設定してください
}
<出力サンプル>
# commit type チェックよう条件式
"docs" | "test" | "feat" | "style" | "perf" | "fix" | "refactor" | "build" | "release" | "snipet" | "security"
# 置換コマンド
sed -e "s/docs\:/$(printf '\xF0\x9F\x93\x9A') &/" -e "s/docs(/$(printf '\xF0\x9F\x93\x9A') &/" \
-e "s/test\:/$(printf '\xF0\x9F\x92\x8A') &/" -e "s/test(/$(printf '\xF0\x9F\x92\x8A') &/" \
-e "s/snipet\:/$(printf '\xF0\x9F\x8D\x84') &/" -e "s/snipet(/$(printf '\xF0\x9F\x8D\x84') &/" \
-e "s/security\:/$(printf '\xF0\x9F\x94\x90') &/" -e "s/security(/$(printf '\xF0\x9F\x94\x90') &/" >> "$1"
上記の内容を commit-msg に反映して下さい
case "$typ" in
"fix" | "feat" | "refactor" | "docs" | "test" | "style" | "perf" | "build" | "release" | "snipet" | "security" )
# ↑ update condition
...
echo "$msg" | # copy and paste sed commnad