LoginSignup
1
2

More than 5 years have passed since last update.

新macを導入時に忘れてしまっていたので備忘録

はじめに

チームで共通言語のひとつとしてPR見るときに便利なので導入する。
そもそも EmojiPrefixってなんなんだって方は下記を御覧ください。

1.pecoを入れる

brew install peco

//そもそもbrewってなにって方は
//https://brew.sh/index_ja

2.導入したいプロジェクトにテンプレートファイルを配置する

vim targetProject/.git/hooks/prepare-commit-msg

中身は下記をコピペ、必要に応じて加筆・修正してください。

#!/bin/sh

out=$1

function message() {
  mv $out $out.tmp
  cat <<EOS > $out
$1
EOS
  cat $out.tmp >> $out
}

str=$(cat <<-EOS
🐛 :bug: fix bugs
👍 :+1: improve function
✨ :sparkles: add new function
♻️ :recycle: refactoring
🚿 :shower: delete unused function
💚 :green_heart: improve tests / CI
👕 :shirt: fix Lint error / fix code style
🚀 :rocket: improve performance
🆙 :up: update package information or libraries
EOS
)
type=$(echo "$str" | peco | awk 'match($0, /(:.*:)/) {print substr($0, RSTART, RLENGTH)}')
message "$type"

3.テンプレートファイルに権限付与

chmod +x targetProject/.git/hooks/prepare-commit-msg

おわりに

あとはそのプロジェクトにおいてgit commit時に自動でprefix選択できるようになるので幸せ。
チームで一つのテンプレートを共有するとなおよし。

1
2
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
1
2