/commitizen

Create committing rules for projects :rocket: auto bump versions :arrow_up: and auto changelog generation :open_file_folder:

Primary LanguagePythonMIT LicenseMIT

Github Actions Conventional Commits PyPI Package latest release Supported versions Codecov

Using commitizen cli


Documentation: https://commitizen-tools.github.io/commitizen/


About

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.

Commitizen features

Requirements

Python 3.6+

Git 1.8.5.2+

Installation

Global installation

sudo pip3 install -U Commitizen

Python project

You can add it to your local project using one of these:

pip install -U commitizen
poetry add commitizen --dev

Usage

Committing

Run in your terminal

cz commit

or the shortcut

cz c

Integrating with Pre-commit

Commitizen can lint your commit message for you with cz check. You can integrate this in your pre-commit config with:

---
repos:
  - repo: https://github.com/commitizen-tools/commitizen
    rev: master
    hooks:
      - id: commitizen
        stages: [commit-msg]

After the configuration is added, you'll need to run

pre-commit install --hook-type commit-msg

Read more about the check command here.

Help

$ cz --help
usage: cz [-h] [--debug] [-n NAME] [--version]
          {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
          ...

Commitizen is a cli tool to generate conventional commits.
For more information about the topic go to https://conventionalcommits.org/

optional arguments:
  -h, --help            show this help message and exit
  --debug               use debug mode
  -n NAME, --name NAME  use the given commitizen (default:
                        cz_conventional_commits)
  --version             get the version of the installed commitizen

commands:
  {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
    init                init commitizen configuration
    commit (c)          create new commit
    ls                  show available commitizens
    example             show commit example
    info                show information about the cz
    schema              show commit schema
    bump                bump semantic version based on the git log
    changelog (ch)      generate changelog (note that it will overwrite
                        existing file)
    check               validates that a commit message matches the commitizen
                        schema
    version             get the version of the installed commitizen or the
                        current project (default: installed commitizen)

Third-Party Commitizen Templates

See Third-Party Commitizen Templates.

FAQ

Why are revert and chore valid types in the check pattern of cz conventional_commits but not types we can select?

revert and chore are added to the "pattern" in cz check in order to prevent backward errors, but officially they are not part of conventional commits, we are using the latest types from Angular (they used to but were removed). However, you can create a customized cz with those extra types. (See Customization

See more discussion in issue #142 and #36

How to handle revert commits?

git revert --no-commit <SHA>
git commit -m "revert: foo bar"

Contributing

See Contributing