pre-commit git commitizen
- Journal 2024-12-01 GitLint
-
cz commit
populates the commit message using a dialog and selection format, much less efficient that UltiSnips and vim-fugitive -
If pre-commit hooks are selected,
cz init
modifies and reorders.pre-commit-config.yaml
, strips comments, and installs.git/hooks/
scripts. The less readable format is not consistent with the typical structure, e.g., Commitizen Integration with Pre-Commit. Leave that option blank duringcz init
. -
cz bump
creates abump:
commit, only if previous commit messages includefeat:
,fix:
, etc.build:
, e.g, does not. The extraneousbump:
clutters the git history. -
In project root, initialize Commitizen with
cz init
.- Please choose a supported config file: pyproject.toml
- Please choose a cz (commit rule): (default: cz_conventional_commits) cz_conventional_commits
- Choose the source of the version: pep621: Get and set version from pyproject.toml:project.version field
- Choose version scheme: semver2
- Please enter the correct version format: (default: "$version")
- Create changelog automatically on bump Yes
- Keep major version zero (0.x) during breaking changes Yes
- What types of pre-commit hook you want to install? (Leave blank if you don't want to install)
-
Select dialog options to update
pyproject.toml
:[tool.commitizen] name = "cz_conventional_commits" tag_format = "$version" version_scheme = "semver2" version_provider = "scm" update_changelog_on_bump = true major_version_zero = true
-
Commitizen Integration with Pre-Commit recommends manually installing
commit-msg
andpre-push
hooks; improve reproducibility by addingstages:
to.pre-commit-config.yaml
:# Commitzen - repo: https://github.com/commitizen-tools/commitizen rev: v4.0.0 hooks: - id: commitizen stages: - commit-msg - id: commitizen-branch stages: - pre-push
-
Update pre-commit hooks and install:
pre-commit autoupdate pre-commit install --install-hooks