DEV Community

Cover image for Git custom commit messages
charly3pins
charly3pins

Posted on • Originally published at charly3pins.dev on

3 3

Git custom commit messages

I've been using the CMF tool for the last one year and I think its simplicity is its potential. Basically it is a terminal tool developd in Go by Walmart Digital that helps you to standarize the commits log of your projects.

I've been using for the last year and a half approximatley and all I can say its very useful. We agreed with the team the configuration we want to use and defined a set of changes that applies in our case. Also we choose the Jira flow and we changed the values for the change adding an emojis to make the commits a bit more funny to check them in the log.

You can install it via npm:

npm install -g go-cmf
Enter fullscreen mode Exit fullscreen mode

or from Go:

go install github.com/walmartdigital/commit-message-formatter
Enter fullscreen mode Exit fullscreen mode

After that, open a terminal and navigate to the root of the project you want to use it. Then type:

cmf init 
Enter fullscreen mode Exit fullscreen mode

You will need to select one of the flows and it will create a .cmf.yaml file with the template of the selected one. You can edit that file in the way you want. The unique condition is that any variable you wanna use have to be defined using {{}}. Example: {{CHANGE}} it will prompt you asking the CHANGE you did and displaying the options you defined in the template.

Here is the .cmf.yaml file that I'm using on this site:

PROMPT:
    - KEY: "CHANGE"
      LABEL: "Type of change"
      OPTIONS:
        - VALUE: "feat :sparkles:"
          DESC: "A new feature"
        - VALUE: "fix :bug:"
          DESC: "A bug fix"
        - VALUE: "test :rotating_light:"
          DESC: "Adding missing tests or correcting wrong ones"
        - VALUE: "style :lipstick:"
          DESC: "A code change to improve clean code"
        - VALUE: "build-ci :construction_worker_man:"
          DESC: "Changes that affect the build system and/or CI configuration files and scripts"
        - VALUE: "refactor :hammer:"
          DESC: "A code change"
        - VALUE: "docs :books:"
          DESC: "Documentation only changes"
        - VALUE: "chore :card_index:"
          DESC: "Changes that don't fit any of the options above"
    - KEY: "MESSAGE"
      LABEL: "Commit message"
TEMPLATE: "{{CHANGE}}: {{MESSAGE}}"
Enter fullscreen mode Exit fullscreen mode

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more