Conventional changelog and commitizen
Last updated
Was this helpful?
Last updated
Was this helpful?
conventional-changelog
, , is a tool to generate a changelog, or release notes, from a project's Git metadata, in particular from commit messages. Its companion high-level tool, standard-version
(), can be used to automatically bump up app version while generating the changelog. The version bump is done according to commits history and follows semver
rules (see ).
For these tools to work properly, the developer must follow some conventions when writing commit messages (at least for commits that close some issues or features implementation), as explained in the official documentation at . In particular, the message format is the following:
where:
type
must be present and can be one of feat
, fix
or some other custom verbs (more on this later). feat
must be used when a commit adds a new feature, fix
when it fixes a bug.
scope
is optional. If present it must be enclosed in parenthesis and describes the changed section of the codebase.
After the type
(or scope
if present), a colon and a space must be present.
description
must be present and is a brief description of the changes in the commit.
body
is optional. If present, there must be a blank line before it. This is a longer description of the changes in the commit.
footer
is optional. If present, there must be a blank line before it. It contains metadata about the commit (e.g. number of task resolved).
If a commit introduces a breaking change, it 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, a space and a mandatory description.
An example of a commit following these rules:
To use standard-version
in your project, just run:
In the Web development world, there are some other commonly used verbs for covnentional commits, but remembering them all is not that easy. Also, formatting commit messages manually is error prone and very tedious.
Install dev dependencies:
Add a config section to package.json
, with the following content:
Add an npm script to use commitizen from CLI:
To use the tool:
Stage your changes as usual (e.g. command line or Git GUI client).
Invoke commitizen wizard. Some ways:
Use the previous npm script via npm run cz
, or
Follow the wizard. That's it!
committizen
() to the rescue! This tool is a simple wizard which will guide the developer during the commit message creation, gathering all required information for well-formed conventional commits. Here is how you can configure it for your project:
Use an extension for your IDE (e.g. for VSCode).