This guide explains how to use commitizen with NEMDataTools to follow the Conventional Commits specification.
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.
type(optional scope): description
[optional body]
[optional footer(s)]
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
The scope is optional and should be a noun describing the section of the codebase affected:
downloadercacheprocessortimeutilstestsdocs
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
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
Use commitizen in interactive mode:
cz commitThis 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)
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.
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
Reference issues at the end of the commit message:
fix(processor): handle missing values in CSV data
Closes #123
- 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
# 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 bumpCommitizen is integrated with NEMDataTools through:
- pre-commit hook: Validates commit messages automatically
- pyproject.toml: Configuration for commitizen
- Development workflow: Used throughout the project development
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.