Commitizen Conventional Commit Guideο
This guide explains how to use commitizen with NEMDataTools to follow the Conventional Commits specification.
What is Commitizen?ο
Commitizen is a tool that helps you write standardized commit messages according to the Conventional Commits format. When used with pre-commit, it ensures all commit messages follow the same format.
Commit Message Formatο
type(optional scope): description
[optional body]
[optional footer(s)]
Typesο
The type must be one of the following:
feat: A new feature
fix: A bug fix
docs: Documentation changes
style: Code style changes (whitespace, formatting, etc.)
refactor: Code changes that neither fix bugs nor add features
perf: Performance improvements
test: Adding or fixing tests
build: Changes to the build system or dependencies
ci: Changes to CI configuration files and scripts
chore: Other changes that donβt modify src or test files
Scopeο
The scope is optional and should be a noun describing the section of the codebase affected:
downloader
cache
processor
timeutils
tests
docs
Descriptionο
The description is a short summary of the code changes. It should:
Use imperative, present tense (e.g., βchangeβ not βchangedβ or βchangesβ)
Not capitalize the first letter
Not end with a period
Examplesο
feat(downloader): add retry mechanism for HTTP requests
fix(cache): resolve file permission issue when creating cache directory
docs: update installation instructions with UV commands
refactor(processor): simplify data standardization function
Creating Commits with Commitizenο
Interactive Modeο
Use commitizen in interactive mode:
cz commit
This will guide you through creating a valid commit message by asking for:
The type of change
The scope (optional)
A short description
A longer description (optional)
Breaking changes (optional)
Issues closed (optional)
Conventional git commitο
You can also write commits directly using the conventional format:
git commit -m "feat(downloader): add support for P5MIN data type"
Pre-commit will validate if the message conforms to the conventional format.
Breaking Changesο
For breaking changes, add a !
after the type/scope and include a BREAKING CHANGE:
footer:
feat(api)!: remove deprecated endpoints
BREAKING CHANGE: The following endpoints have been removed as they were deprecated in v0.5.0
Referencing Issuesο
Reference issues at the end of the commit message:
fix(processor): handle missing values in CSV data
Closes #123
Benefits of Using Commitizenο
Standardized history: Makes the project history readable and structured
Automated versioning: Can be used to automatically determine version numbers
Automated changelog: Simplifies generating changelogs from commit messages
Clarity: Clearly communicates the intent of changes
Commitizen CLI Commandsο
# Create a commit interactively
cz commit
# Check if the last commit message follows the convention
cz check --rev-range HEAD
# Bump version based on commits (when ready for release)
cz bump
Integration with NEMDataToolsο
Commitizen is integrated with NEMDataTools through:
pre-commit hook: Validates commit messages automatically
pyproject.toml: Configuration for commitizen
Development workflow: Used throughout the project development
Customizing Commitizenο
You can customize commitizen by adding a configuration to your pyproject.toml
:
[tool.commitizen]
name = "cz_conventional_commits"
version = "0.1.0"
tag_format = "v$version"
This ensures everyone on the project follows the same commit conventions.