Conventional commits

  • avatar
  • 2.3K Views
  • 15 Likes
  • 3 mins read

The Conventional Commits specification is 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.

Message structure

The commit message should be structured as follows:

<type>[optional scope]: <description>

[optional body]

[optional footer]

The type of the commit, intended to describe the category of your change, and a brief description of the change shape conventional commits basic format. A scope may be provided (within parenthesis) to a commit's type for additional contextual information. In the body section we can describe in detail the alterations made by the commit.

A commit that has a footer BREAKING CHANGE: or appends a ! after the type/scope, introduces a breaking change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.

Commit types

Every commit has a type that falls into one of the following predefined categories:

Name

Type

Description

feat

Features

A new feature

fix

Bug Fixes

A bug fix

docs

Documentation

Documentation changes only

style

Styles

Changes that do not affect the meaning of the code (tabs, spaces, formatting, etc...)

refactor

Code Refactoring

A code change that neither fixes a bug nor adds a feature

perf

Performance Improvements

A code change that improves performance

test

Tests

Adding missing tests or correcting existing tests

build

Builds

Changes that affect the build system or external dependencies

ci

Continuous Integrations

Changes to our CI configuration files and scripts

chore

Chores

Other changes that don't modify src or test files

revert

Reverts

Reverts a previous commit

Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

  1. Commits MUST be prefixed with a type, which consists of a noun, feat, fix, etc., followed by a colon and a space.

  2. The type feat MUST be used when a commit adds a new feature to your application or library.

  3. The type fix MUST be used when a commit represents a bug fix for your application.

  4. An optional scope MAY be provided after a type. A scope is a phrase describing a section of the codebase enclosed in parenthesis, e.g., fix(parser):

  5. A description MUST immediately follow the type/scope prefix. The description is a short description of the code changes, e.g., fix: array parsing issue when multiple spaces were contained in string.

  6. A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description.

  7. A footer MAY be provided one blank line after the body. The footer SHOULD contain additional issue references about the code changes (such as the issues it fixes, e.g., Fixes #13).

  8. Breaking changes MUST be indicated at the very beginning of the footer or body section of a commit. A breaking change MUST consist of the uppercase text BREAKING CHANGE, followed by a colon and a space.

  9. A description MUST be provided after the BREAKING CHANGE:, describing what has changed about the API, e.g., BREAKING CHANGE: environment variables now take precedence over config files.

  10. The footer MUST only contain BREAKING CHANGE, external links, issue references, and other meta-information.

  11. Types other than feat and fix MAY be used in your commit messages.

 Join Our Monthly Newsletter

Get the latest news and popular articles to your inbox every month

We never send SPAM nor unsolicited emails

0 Comments

Leave a Reply

Your email address will not be published.

Replying to the message: View original

Hey visitor! Unlock access to featured articles, remove ads and much more - it's free.