Adds emojis and infers commit context for people who use conventional commits
- install it as git hooks:
prepare-commit-msg and commit-msg
- follow git conventional commits: https://www.conventionalcommits.org/en/v1.0.0-beta.2/
- ???
- PROFIT
Open GIF spoiler
demo on streamable: https://streamable.com/n0u5p
webm: https://github.com/ColCh/git-commit-msg/blob/master/demo/demo.webm
This hook currently does that:
- Prepend emoji before git commit type. Predefined types are here:
|
const commitTypeToEmoji = { |
|
chore: 'π', |
|
docs: 'π', |
|
feat: 'β', |
|
fix: 'π ', |
|
refactor: 'β»', |
|
style: 'π', |
|
test: 'π', |
|
type: 'π·', |
|
perf: 'β‘', |
|
ci: 'π€', |
|
}; |
- Mark words with predefined emoji defined here:
|
const markWordsWithEmoji = { |
|
update: 'β¬ ', |
|
add: 'β', |
|
remove: 'β', |
|
change: 'π', |
|
rename: 'π', |
|
package: 'π¦', |
|
deploy: 'π¦', |
|
fix: 'π ', |
|
webpack: ' π', |
|
increase: 'π ', |
|
decrease: ' π', |
|
copy: ' π', |
|
config: 'βοΈ', |
|
configure: 'βοΈ', |
|
optimize: ' π', |
|
typo: ' π', |
|
}; |
. Example:
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "add" should match snapshot 1`] = `"some msg β add some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "change" should match snapshot 1`] = `"some msg π change some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "config" should match snapshot 1`] = `"some msg βοΈ config some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "configure" should match snapshot 1`] = `"some msg βοΈ configure some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "copy" should match snapshot 1`] = `"some msg π copy some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "decrease" should match snapshot 1`] = `"some msg π decrease some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "deploy" should match snapshot 1`] = `"some msg π¦ deploy some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "fix" should match snapshot 1`] = `"some msg π fix some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "increase" should match snapshot 1`] = `"some msg π increase some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "optimize" should match snapshot 1`] = `"some msg π optimize some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "package" should match snapshot 1`] = `"some msg π¦ package some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "remove" should match snapshot 1`] = `"some msg β remove some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "rename" should match snapshot 1`] = `"some msg π rename some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "typo" should match snapshot 1`] = `"some msg π typo some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "update" should match snapshot 1`] = `"some msg β¬ update some msg"`; |
|
|
|
exports[`main test for git-commit-msg mark words with emoji per-word tests given word "webpack" should match snapshot 1`] = `"some msg π webpack some msg"`; |
- Try to infer git commit context. Example:
|
# Found 3 contexts |
|
# * modified-file |
|
# * deleted-file |
|
# * new-file |
yarn global add @colch/git-commit-msg
add git-commit-msg into prepare-commit-msg and commit-msg hooks:
git-commit-msg $1
to appear like that:

pass it like env variables