GitHub CLI Extension for Conventional Commits

robvanderleek

Rob van der Leek

Posted on October 25, 2024

GitHub CLI Extension for Conventional Commits

Image description

A new GitHub CLI extension called gh-cc makes it easy to turn all your commits into conventional commits.
Read below about the advantages of using conventional commits, or skip ahead to the installation section.

Improving your commit history

Conventional Commits is a guideline to improve the readability of commit messages. For example, if a commit fixes a bug in the code, a normal commit message looks like this:

Do not crash on empty index field
Enter fullscreen mode Exit fullscreen mode

The same commit message, but now in a conventional style, looks like this:

fix: ๐Ÿ› Do not crash on empty index field
Enter fullscreen mode Exit fullscreen mode

The prefix helps both humans and machines to better understand the main intent of the commit.

Improved readability for humans

Compare the git histories (git log --oneline) below, which one is easier to grasp?

Normal commit log:

36d23b5 Add filter for new matches
d5d96ee Do not crash on empty index field
4f0f722 Keep less data in memory
70fcb38 Update dependencies
b5432ee Bump version to 0.15.0
b69b9c4 Update FAQ section
Enter fullscreen mode Exit fullscreen mode

Conventional commit log:

36d23b5 feat: โœจ Add filter for new matches
d5d96ee fix: ๐Ÿ› Do not crash on empty index field
4f0f722 perf: โšก๏ธ Keep less data in memory
70fcb38 build: โฌ†๏ธ Update dependencies
b5432ee build: ๐Ÿ”– Bump version to 0.15.0
b69b9c4 docs: ๐Ÿ“ Update FAQ section
Enter fullscreen mode Exit fullscreen mode

Improved readability for machines

Because conventional commits add a consistent prefix to your commit messages, automated tools can parse this prefix and use it for other nice things. One of these things is making your project follow the Semantic Versioning specification by automatically creating semantic releases. The screenshot below shows how pretty your generated release documentation becomes by using conventional commmits:

Image description

Installation

If you have the GitHub CLI up and running, installing the extension is as simple as:

gh ext install robvanderleek/gh-cc
Enter fullscreen mode Exit fullscreen mode

Usage

Type the following inside any cloned repository:

gh cc -am "commit message here"
Enter fullscreen mode Exit fullscreen mode

This extension passes all arguments on to git commit, so to save typing you can add the following alias to your shell configuration: alias gc="gh cc". The command above then becomes:

gc -am "commit message here"
Enter fullscreen mode Exit fullscreen mode

That's it!

Request for feedback

This GH CLI extension implements the Angular convention for commit types, combined with gitmojis. It does not support scopes, or message bodies. For feedback, suggestions and bug reports, please open an issue.

Examples of more advanced tools for conventional commits can be found here.

Cover image by BRRT from Pixabay

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
robvanderleek
Rob van der Leek

Posted on October 25, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About