Régis N.

Oct 2023

The new version and usage of gcommit, a cli too to make conventional git commit messages

5 min rust

Later this week I was walking around in Github, searching for rust codebases and seeing what can be built with rust. I came accross a project called gcommit, which had this fuctionality of helping you write better conventional commit messages. I found thi interesting and as I was learning rust in those days, I folked it and coolified it 😉.

How the tool was before

It's only feature was just giving a dialog to fill in information about you commit once the user types gcommit in their terminal which is the one that attracted me to take my spare time and add more features in this tool.

What I added

First, I started by adding a feature of commiting in a single line. used a crate called clap to handle args and add this whole feature, It's a awesome tool, most rustaceans use it.

>_ gcommit -c <type> -s <scope> -m <commit_message>

Next, I added a feature of configuring gcommit using a file so that development teams and open source projects can integrate gcommit in their workflow. I decided to use yaml instead of json, mainly because yaml is lightweight and easy to write, just like making indented lists. I also added a validation feature, which validates commit types and scopes based on the configurations.

When you type gcommit in terminal in your repo's base directory for the first time, it creates .gcommit.yml automatically with default configurations.

>_ gcommit
Found no .gcommit.yml, creating a default one...

The default configurations look like this:

# file-name: .gcommit.yml 
classes:
  feat:   A new feature
  fix:    A bug fix
  docs:   Documentation only changes
  style:  Changes that do not affect the meaning of the code
  perf:   A code change that improves performance
  test:   Adding missing tests
  chore:  Changes to the build process or auxiliary tools and libraries

scopes:
  - web
  - api
  - docs

The default config is based on proper commit conventions accross the open source community.

Getting started with gcommit

The new version (v0.0.4) of gcommit is now released, you can download a binary for your platform here After installation, type gcommit --help to get the cli help

$ gcommit --help
Usage: gcommit.exe [OPTIONS]

Options:
  -c, --class              Classification or type of commit
  -s, --scope              Project scope where changes were made
  -m, --message            Commit message
  -h, --help               Print help
  -V, --version            Print version

Outro

Even if this tool might have sounded as something cool to you, it's not actively maintained currently, in fact, when i found it, its latest commit was in 2 years, for serious projects, I recommend using tools like commitlint or commitzen.