Enjoy your commit with gitmoji-c

sa.nitawaki
4 min readJun 30, 2019

--

https://gitmoji.carloscuesta.me/

My company has a ‘gitmoj’ culture.
This is the practice of putting ‘gitmoji’ at the beginning of the commit message when committing.

For example, The commit of Android is linked to the following emoji

You just add this to your prefix at git commit.

:robot: Build Error Fix

Then

Looks like this on github.
It makes it easy to understand, “Does this fix Anroid’s build error?”

It’s just fun.
And the amount of information on commit messages will increase steadily.

When you look for the old commit, just get tired.

But if you have a gitmoji commit message your can filter by ‘:robot:’ and your can find it right away.

$ git log --oneline --grep :robot
xxxxxxx :robot::lipstick:[AIRCLOSET-2010] Fix: TextInputでタブバーが押し上げられる現象fix
The boring commit list is also gourgeous thanks to gitmoji.

Problem 1: The trouble of finding the gitmoji code

gitmoji is published on the web page.
https://gitmoji.carloscuesta.me/

Went to the site every time I made a commit.
This is a bother!

When you make a rare commit, you have to look into it.

ex: wip, fix CI etc…

Problem 2: Typo

You don’t need to explain it.
Yes, it’s typo…

No Coool!!

My Solution

There is something like gitmoji-cli.

This is a great CLI tool.
gitmoji list, search, commit… there is a desired function.

But. There is one complaint.

Ask for gpg at commit time.
Is seems to solve if you set something, but it is not cool to ask for by default.

It was easy, so I made My gitmoji-cli!

gitmoji-c

$ yarn global add gitmoji-c

Show gitmoji list:

$ gitmoji list 

Search gitmoji:

$ gitmoji list -s <search word>
# or
$ gitmoji list --search=<search word>
# or
$ gitmoji list <search word>

Commit of gitmoji:

$ gitmoji commit

In the case of me, I’m planning to extend the function to gitmoji-c because there is a need to “write more than one gitmoji by commit”!

Gitmoji is also displayed on the your terminal.

How to Create?

oclif

I made it with Node and TypeScript.
The oclif is excellent, and it provides a good environment at the time of initial.

inquirer

The gitmoji-c commit is a response CLI.

  1. Select gitmoji
  2. Input commit title
  3. Input commit message

You will be ased to enter.

An implementer of this response CLI is ‘inquirer’.

Originally intended to use ‘enquirer’, but did not know how to present options based on external data.

class Prompt {
public get questions() {
return [
{
name: 'gitmoji',
message: 'Choose a gitmoji:',
type: 'autocomplete',
async source(_: any, input: { toLowerCase(): void; }) {
const emojiList = await gitmojis()
const searchResult = emojiList.filter((gitmoji: IGitmoji) => {
const emoji = gitmoji.name.concat(gitmoji.description).toLowerCase()
// @ts-ignore
return (!input || emoji.indexOf(input.toLowerCase()) !== -1)
})

return displayValue(searchResult)
}
},
{
name: 'title',
message: 'Enter the commit title',
},
{
name: 'message',
message: 'Enter the commit message:',
},
]
}
}

--

--

sa.nitawaki
sa.nitawaki

Responses (1)