Conventional commit: the way to writing Good commits

Jun 18th 21

As the software ecosystems continue to grow in complexity, teams on a software projects also increase in numbers, Source Control Systems like Github, Gitlab, AWS CodeCommit, Apache Subversion has created various bits of solutions and tools to make the process much more easier.

commit messages which are description of changes made to code repositories at a point in time are meant to be great tool if it is properly written, in other to improve the quality of commit messages, teams come with different rules meant to help there members write better commit messages.

Recently, I was starting a projects and was searching for ways to enforce all code commit messages to follow a predefined patterns, more like a conventional way of writing commit message for the project, an approved syntax of a commit message, and yes, I came a across conventionalcommits.org.

a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of it. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.

conventional commit has been around for quite a while has gained a lot of attractions by some of the large teams, from Microsoft, Google, currently repositories like Yargs, Electron, Jenkins applies this convention.

Deep dive into conventional commits,

The conventional commits syntax structure contains the following items organize just the way they propose.

Type: The type structural element describes the type of changes being committed, it could any of

  • Bug - used to commit changes that fixes a bug
  • Feat - commits new features code changes.

Scope: scope provides additional contextual information to the commit type

Description: describe a the changes made Body: the optional body part of the commit should provide additional information, links to an issue, or a jira task or to an external context. Footer: provider information if the commit is BREAKING CHANGE

<type>[optional scope]: <description> [optional body] [optional footer(s)]

Examples:

Commit message with description and breaking change footer

feat:allow provided config object to extend other configs BREAKING CHANGE: extends key in config file is now used for extending other config files

Commit message with ! to draw attention to breaking change

refactor!: drop support for Node 6

Commit message with both ! and BREAKING CHANGE footer

refactor!: drop support for Node 6 BREAKING CHANGE: refactor to use JavaScript features not available in Node 6.

Commit message with no body

docs: correct spelling of CHANGELOG

Commit message with scope

feat(lang): add polish language

Multiple tools has been built around conventionalcommits to help ensure the convention is followed through by all member of the team regardless of your environments.

Vscode's library VScode Conventional Commits and different other libraries/plugins exists for different languages.

commitizen-tools/commitizen: A tool written in Python to create commit rules for projects, auto bump versions and auto changelog generation.

php-commitizen: A PHP tool built to create commit messages following the Conventional Commits specifications. configurable and usable for PHP projects as a composer dependency or usable globally for non-PHP projects.

python-semantic-release: Automatic Semantic Versioning for Python projects. This is a Python implementation of the semantic-release for Node.js.

VSCode Conventional Commits: Add Conventional Commits supports for VSCode.

Pyhist: A Python utility to automagically update the package version from the git history and generate the Changelog.

Versio: A monorepo-compatible tool that updates version numbers based on conventional commits and project dependencies. It can generate tags and changelogs, too.

These tools help developers write commit messages that assists fellow developers, devOps and also contributes to automations.

Contribution In the start of every software engineers career the goal is always to learn the languages, understand algorithms, solve problems, build and ship live software, but as the experience gather and we work on more complex applications and larger team, over time we realise that not only do we need to write clean codes but we have to write contents that assists the team and provides informations for better decision making.

Conventional commits is a great tool, that help enforce the behaviours especially to new developers, it will introduce the importance of commit messages when done write.

Get the Latest Information


© 2022, Enwemasor Barnabas