It's high time to change to conventional commits

It's high time to change to conventional commits

Commitizen - conventional commits

Introduction

Commitizen is a tool designed for teams.

Its main purpose is to define a standard way of committing rules and communicating it (using the cli provided by commitizen).

The reasoning behind it is that it is easier to read, and enforces writing descriptive commits.

Besides that, having a convention on your commits makes it possible to parse them and use them for something else, like generating automatically the version or a changelog.

Installation

Installation is as simple as running the following command

npm install -g commitizen

Usage

Simply use

git cz

or just cz instead of git commit when committing. You can also use git-cz, which is an alias for cz.

Alternatively, use npx instead

npx cz

Add a script "commit": "cz" inside the package.json

"scripts": {
    "commit": "cz",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

Now, Instead of using the "git commit" after the traditional command "git add " you can use "npm run commit" inside your repository which will run the script command "cz" which is inside the package.json to provide commitizen conventional questions as like below

commitizen-add-commit.png

After answering the questions it will create a commit with conventional commit standard as per below

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Commit message example

fix: prevent racing of requests

Introduce a request id and a reference to latest request. Dismiss
incoming responses other than from latest request.

Remove timeouts which were used to mitigate the racing issue but are
obsolete now.

Reviewed-by: Z
Refs: #123

###Advantage of using Conventional Commit

  1. Automatically generating CHANGELOGs.
  2. Automatically determining a semantic version bump (based on the types of commits landed).
  3. Communicating the nature of changes to teammates, the public, and other stakeholders.
  4. Triggering build and publish processes.
  5. Making it easier for people to contribute to your projects, by allowing them to explore a more structured commit history.

References / Credits / Source:

  1. commitizen-tools.github.io/commitizen
  2. npmjs.com/package/commitizen
  3. conventionalcommits.org/en/v1.0.0