Skip to content

Instantly share code, notes, and snippets.

@keitakn
Forked from mesh1nek0x0/prepare-commit-msg
Last active November 4, 2021 01:55
Show Gist options
  • Select an option

  • Save keitakn/4a5e687496825fd81e3095d872e4bc7b to your computer and use it in GitHub Desktop.

Select an option

Save keitakn/4a5e687496825fd81e3095d872e4bc7b to your computer and use it in GitHub Desktop.
my prepare-commit-msg
#!/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 "
@keitakn
Copy link
Author

keitakn commented Jun 10, 2018

下記のインストールが必要

https://github.com/peco/peco

@keitakn
Copy link
Author

keitakn commented Dec 3, 2019

配置したスクリプトには実行権限を与えておく必要がある。

chmod 755 /usr/local/etc/git-hooks/prepare-commit-msg

@keitakn
Copy link
Author

keitakn commented Nov 4, 2021

最近は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