Gitmoji helper written with β€οΈ in Go. Inspired by gitmoji-cli.
Install using Homebrew:
brew install jamesdobson/gogitmoji/gogitmoji
gitmoji help
gogitmoji helps you write git commit messages containing gitmoji!
Usage:
gitmoji [flags]
gitmoji [command]
Available Commands:
commit β‘οΈ Compose a commit message and execute git commit (default command)
export π’ Export a commit template
help π Help about any command
info π Open gimoji information page in gyour browser
list π List all available gitmoji
update π Update the list of gitmoji
version βΉοΈ Display the version of this program
Flags:
--config string config file (default is $HOME/.gitmoji/config.yaml)
-h, --help help for gitmoji
Use "gitmoji [command] --help" for more information about a command.
Guides the user through the process of composing a commit message, and then
executes git commit
.
gitmoji commit
commit
is the default command, so just the following is equivalent:
gitmoji
You can configure git to run gogitmoji automatically when you execute git commit
,
so that you don't always have to remember to type gitmoji
. To do so, just
set up a git hook in your git repositories:
#!/bin/sh
exec < /dev/tty
gitmoji hook do $1
exit $?
Place the above in the file <my repo>/.git/hooks/prepare-commit-msg
and ensure
the file is executable (e.g. chmod a+x prepare-commit-msg
)
Prints the list of gitmoji.
gitmoji list
π¨ - :art: Improving structure / format of the code.
β‘οΈ - :zap: Improving performance.
π₯ - :fire: Removing code or files.
π - :bug: Fixing a bug.
π - :ambulance: Critical hotfix.
β¨ - :sparkles: Introducing new features.
π - :pencil: Writing docs.
π - :rocket: Deploying stuff.
π - :lipstick: Adding or updating the UI and style files.
π - :tada: Begining a project.
β
- :white_check_mark: Adding or updating tests.
π - :lock: Fixing security issues.
π - :bookmark: Releasing / Version tags.
π¨ - :rotating_light: Removing linter warnings.
π§ - :construction: Work in progress.
π - :green_heart: Fixing CI Build.
β¬οΈ - :arrow_down: Downgrading dependencies.
β¬οΈ - :arrow_up: Upgrading dependencies.
π - :pushpin: Pinning dependencies to specific versions.
π· - :construction_worker: Adding or updating CI build system.
π - :chart_with_upwards_trend: Adding or updating analytics or tracking code.
β»οΈ - :recycle: Refactoring code.
β - :heavy_plus_sign: Adding a dependency.
β - :heavy_minus_sign: Removing a dependency.
π§ - :wrench: Adding or updating configuration files.
π¨ - :hammer: Adding or updating build scripts.
π - :globe_with_meridians: Internationalization and localization.
βοΈ - :pencil2: Fixing typos.
π© - :poop: Writing bad code that needs to be improved.
βͺ - :rewind: Reverting changes.
π - :twisted_rightwards_arrows: Merging branches.
π¦ - :package: Adding or updating compiled files or packages.
π½ - :alien: Updating code due to external API changes.
π - :truck: Moving or renaming files.
π - :page_facing_up: Adding or updating license.
π₯ - :boom: Introducing breaking changes.
π± - :bento: Adding or updating assets.
βΏοΈ - :wheelchair: Improving accessibility.
π‘ - :bulb: Adding or updating comments in source code.
π» - :beers: Writing code drunkenly.
π¬ - :speech_balloon: Adding or updating text and literals.
π - :card_file_box: Performing database related changes.
π - :loud_sound: Adding or updating logs.
π - :mute: Removing logs.
π₯ - :busts_in_silhouette: Adding or updating contributor(s).
πΈ - :children_crossing: Improving user experience / usability.
π - :building_construction: Making architectural changes.
π± - :iphone: Working on responsive design.
π€‘ - :clown_face: Mocking things.
π₯ - :egg: Adding or updating an easter egg.
π - :see_no_evil: Adding or updating a .gitignore file
πΈ - :camera_flash: Adding or updating snapshots
β - :alembic: Experimenting new things
π - :mag: Improving SEO
π·οΈ - :label: Adding or updating types (Flow, TypeScript)
π± - :seedling: Adding or updating seed files
π© - :triangular_flag_on_post: Adding, updating, or removing feature flags
π₯
- :goal_net: Catching errors
π« - :dizzy: Adding or updating animations and transitions
π - :wastebasket: Deprecating code that needs to be cleaned up.
Checks to see if there is a new list of gitmoji online, updating the local cache if there are new gitmoji.
gitmoji update
The configuration file is stored at ~/.gitmoji/config.yaml
. The config file
can specify the following:
- Default commit template
- Enable "scope" prompt
- Emoji format
- New commit templates
Specify the name of the default commit template:
template: "conventional"
Enable / disable prompting for commit scope:
scope: True
Note: this is used by the default gitmoji
template, but has no effect on the
default conventional
template. This can be changed by defining a custom
template and using the enablesetting
field on the corresponding Prompt
.
The emoji format can be set to either emoji
(its default value) or code
:
format: code
When set to emoji
, the UTF-8 bytes encoding the emoji will be used in the
commit message. When set to code
, an text string (e.g. :sparkles:
) will be
used. GitHub will render this as an emoji.
The configuration file allows the definition of new commit templates. A commit template has three parts:
- The command to run
- Arguments to the command
- User prompts of inputs for the arguments
The following example demonstrates all three elements:
templates:
example:
Command: echo
CommandArgs:
- Hello, {{ .name }}, I'm pleased to meet you.
Prompts:
- prompttype: text
mandatory: true
prompt: Enter your name
valuecode: name
This example prompts the user to enter their name, and then echoes it back to them as a polite greeting:
jamesdobson@MacBook-Pro gitmoji % gitmoji commit -t example
Using config file: /Users/jamesdobson/.gitmoji/config.yaml
β Enter your name: James
Going to execute: echo "Hello, James, I'm pleased to meet you."
Execute: y
Executing...
Hello, James, I'm pleased to meet you.
gogitmoji done.
In this example, the command is echo
. In most cases, however, Command
should
be set to git
.
The arguments to the command are expressed as an array under the CommandArgs
section. Each argument is a Go template
that can refer to inputs that come from the user prompts. If an argument evaluates
to the empty string, it is skipped.
The final section, Prompts
, is an array of user prompts. There are 3 kinds of
user prompt, differentiated by their Type
field:
text
: Prompts the user with the text inPrompt
, and waits for the user to enter a text response.choice
: Prompts the user with a selection of options as given by theChoices
field.gitmoji
: Prompts the user with a list of gitmoji.
The result of the prompt is stored under the name given by the Name
field and
is made available in the command arguments via the {{ .xyz }}
syntax, where
xyz
is whatever was specified in the Name
field.
There is an additional section, Messages
, that is used when gogitmoji is called
as a commit hook. In this case, no command is executed (because commit is already
running) however the Messages
are evaluated and written to the file that git
provides to the commit hook as an argument.
This is the default gitmoji
commit template:
templates:
gitmoji:
Command: git
CommandArgs:
- commit
- -m
- '{{if eq (getString "format") "emoji"}}{{.gitmoji.Emoji}} {{else}}{{.gitmoji.Code}}{{end}}
{{with .scope}}({{.}}): {{end}}{{.title}}'
- '{{with .message}}-m{{end}}'
- '{{.message}}'
Messages:
- '{{if eq (getString "format") "emoji"}}{{.gitmoji.Emoji}} {{else}}{{.gitmoji.Code}}{{end}}
{{with .scope}}({{.}}): {{end}}{{.title}}'
- '{{.message}}'
Prompts:
- Type: gitmoji
Mandatory: true
Name: gitmoji
- Type: text
Prompt: Enter the scope of current changes
Name: Scope
Condition: scope
- Type: text
Mandatory: true
Prompt: Enter the commit title
Name: title
- Type: text
Prompt: Enter the (optional) commit message
Name: message
This is the default conventional
commit template:
templates:
conventional:
Command: git
CommandArgs:
- commit
- -m
- '{{.type}}: {{.description}}'
- '{{with .body}}-m{{end}}'
- '{{.body}}'
- '{{with .footer}}-m{{end}}'
- '{{.footer}}'
Messages:
- '{{.type}}: {{.description}}'
- '{{.body}}'
- '{{.footer}}'
Prompts:
- Type: choice
Mandatory: true
Prompt: 'Choose the type of commit:'
Name: type
Choices:
- Value: feat
Description: A new feature.
- Value: fix
Description: A bug fix.
- Value: docs
Description: Documentation only changes.
- Value: perf
Description: A code change that improves performance.
- Value: refactor
Description: A code change that neither fixes a bug nor adds a feature.
- Value: test
Description: Adding missing or correcting existing tests.
- Value: chore
Description: Changes to the build process or auxiliary tools and libraries
such as documentation generation.
- Type: text
Mandatory: true
Prompt: Enter the commit description, with JIRA number at end
Name: description
- Type: text
Prompt: Enter the (optional) commit body
Name: body
- Type: text
Prompt: Enter the (optional) commit footer
Name: footer
Licensed under the MIT license.
The gitmoji database is from Gitmoji.