Debian Codegraph @

docs/README.md

raw
1 [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/commitizen-tools/commitizen/pythonpackage.yml?label=python%20package&logo=github&logoColor=white&style=flat-square)](https://github.com/commitizen-tools/commitizen/actions)
2 [![Check Links](https://github.com/commitizen-tools/commitizen/actions/workflows/links.yml/badge.svg)](https://github.com/commitizen-tools/commitizen/actions/workflows/links.yml)
3 [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)
4 [![PyPI Package latest release](https://img.shields.io/pypi/v/commitizen.svg?style=flat-square)](https://pypi.org/project/commitizen/)
5 [![PyPI Package download count (per month)](https://img.shields.io/pypi/dm/commitizen?style=flat-square)](https://pypi.org/project/commitizen/)
6 [![Supported versions](https://img.shields.io/pypi/pyversions/commitizen.svg?style=flat-square)](https://pypi.org/project/commitizen/)
7 [![Conda Version](https://img.shields.io/conda/vn/conda-forge/commitizen?style=flat-square)](https://anaconda.org/conda-forge/commitizen)
8 [![homebrew](https://img.shields.io/homebrew/v/commitizen?color=teal&style=flat-square)](https://formulae.brew.sh/formula/commitizen)
9 [![Codecov](https://img.shields.io/codecov/c/github/commitizen-tools/commitizen.svg?style=flat-square)](https://codecov.io/gh/commitizen-tools/commitizen)
10 [![prek](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json&style=flat-square&color=brightgreen)](https://github.com/j178/prek)
11
12 ![Using Commitizen cli](images/cli_interactive/commit.gif)
13
14 ---
15
16 [**Commitizen Documentation Site**](https://commitizen-tools.github.io/commitizen/)
17
18 ---
19
20 ## About
21
22 Commitizen is a powerful release management tool that helps teams maintain consistent and meaningful commit messages while automating version management.
23
24 ### What Commitizen Does
25
26 By enforcing standardized commit conventions (defaulting to [Conventional Commits][conventional_commits]), Commitizen helps teams:
27
28 - Write clear, structured commit messages
29 - Automatically manage version numbers using semantic versioning
30 - Generate and maintain changelogs
31 - Streamline the release process
32
33 ### Key Benefits
34
35 With just a simple `cz bump` command, Commitizen handles:
36
37 1. **Version Management**: Automatically bumps version numbers and updates version files based on your commit history
38 2. **Changelog Generation**: Creates and updates changelogs following the [Keep a changelog][keepchangelog] format
39 3. **Commit Standardization**: Enforces consistent commit message formats across your team
40
41 This standardization makes your commit history more readable and meaningful, while the automation reduces manual work and potential errors in the release process.
42
43 ### Features
44
45 - Interactive CLI for standardized commits with default [Conventional Commits][conventional_commits] support
46 - Intelligent [version bumping](https://commitizen-tools.github.io/commitizen/commands/bump/) using [Semantic Versioning][semver]
47 - Automatic [keep a changelog][keepchangelog] generation
48 - Built-in commit validation with pre-commit hooks
49 - [Customizable](https://commitizen-tools.github.io/commitizen/customization/config_file/) commit rules and templates
50 - Multi-format version file support
51 - Custom rules and plugins via pip
52
53 ## Getting Started
54
55 ### Requirements
56
57 Before installing Commitizen, ensure you have:
58
59 - [Python](https://www.python.org/downloads/) `3.10+`
60 - [Git][gitscm] `1.8.5.2+`
61
62 ### Installation
63
64 #### Global Installation (Recommended)
65
66 The recommended way to install Commitizen is using [`pipx`](https://pipx.pypa.io/) or [`uv`](https://docs.astral.sh/uv/), which ensures a clean, isolated installation:
67
68 **Using pipx:**
69 ```bash
70 # Install Commitizen
71 pipx install commitizen
72
73 # Keep it updated
74 pipx upgrade commitizen
75 ```
76
77 **Using uv:**
78 ```bash
79 # Install commitizen
80 uv tool install commitizen
81
82 # Keep it updated
83 uv tool upgrade commitizen
84 ```
85
86 **(For macOS users) Using Homebrew:**
87 ```bash
88 brew install commitizen
89 ```
90
91 #### Project-Specific Installation
92
93 You can add Commitizen to your Python project using any of these package managers:
94
95 **Using pip:**
96 ```bash
97 pip install -U commitizen
98 ```
99
100 **Using conda:**
101 ```bash
102 conda install -c conda-forge commitizen
103 ```
104
105 **Using Poetry:**
106 ```bash
107 # For Poetry >= 1.2.0
108 poetry add commitizen --group dev
109
110 # For Poetry < 1.2.0
111 poetry add commitizen --dev
112 ```
113
114 **Using uv:**
115 ```bash
116 uv add --dev commitizen
117 ```
118
119 **Using pdm:**
120 ```bash
121 pdm add -d commitizen
122 ```
123
124 ### Basic Commands
125
126 #### Initialize Commitizen
127
128 To get started, run the `cz init` command. This will guide you through the process of creating a configuration file with your preferred settings.
129
130 #### Create Commits
131
132 Create standardized commits using:
133 ```sh
134 cz commit
135 # or use the shortcut
136 cz c
137 ```
138
139 To sign off your commits:
140 ```sh
141 cz commit -- --signoff
142 # or use the shortcut
143 cz commit -- -s
144 ```
145
146 For more commit options, run `cz commit --help`.
147
148 #### Version Management
149
150 The most common command you'll use is:
151 ```sh
152 cz bump
153 ```
154
155 This command:
156
157 - Bumps your project's version
158 - Creates a git tag
159 - Updates the changelog (if `update_changelog_on_bump` is enabled)
160 - Updates version files
161
162 You can customize:
163
164 - [Version files](https://commitizen-tools.github.io/commitizen/commands/bump/#version_files)
165 - [Version scheme](https://commitizen-tools.github.io/commitizen/commands/bump/#version_scheme)
166 - [Version provider](https://commitizen-tools.github.io/commitizen/config/version_provider/)
167
168 For all available options, see the [bump command documentation](https://commitizen-tools.github.io/commitizen/commands/bump/).
169
170 ### Advanced Usage
171
172 #### Get Project Version
173
174 ```sh
175 # Get your project's version (instead of Commitizen's version)
176 cz version -p
177 # Preview changelog changes
178 cz changelog --dry-run "$(cz version -p)"
179 ```
180
181 This command is particularly useful for automation scripts and CI/CD pipelines.
182
183 For example, you can use the output of the command `cz changelog --dry-run "$(cz version -p)"` to notify your team about a new release in Slack.
184
185 #### Prek and Pre-commit Integration
186
187 Commitizen can automatically validate your commit messages using pre-commit hooks.
188
189 1. Add to your `.pre-commit-config.yaml`:
190 ```yaml
191 ---
192 repos:
193 - repo: https://github.com/commitizen-tools/commitizen
194 rev: master # Replace with latest tag
195 hooks:
196 - id: commitizen
197 - id: commitizen-branch
198 stages: [pre-push]
199 ```
200
201 2. Install the hooks:
202 ```sh
203 prek install --hook-type commit-msg --hook-type pre-push
204 ```
205
206 | Hook | Recommended Stage |
207 | ----------------- | ----------------- |
208 | commitizen | commit-msg |
209 | commitizen-branch | pre-push |
210
211 > **Note**: Replace `master` with the [latest tag](https://github.com/commitizen-tools/commitizen/tags) to avoid warnings. You can automatically update this with:
212 > ```sh
213 > prek autoupdate
214 > ```
215
216 For more details about commit validation, see the [check command documentation](https://commitizen-tools.github.io/commitizen/commands/check/).
217
218 ## Help & Reference
219
220 ### Command Line Interface
221
222 Commitizen provides a comprehensive CLI with various commands. Here's the complete reference:
223
224 ![cz --help](images/cli_help/cz___help.svg)
225
226 ### Quick Reference
227
228 | Command | Description | Alias |
229 |---------|-------------|-------|
230 | `cz init` | Initialize Commitizen configuration | - |
231 | `cz commit` | Create a new commit | `cz c` |
232 | `cz bump` | Bump version and update changelog | - |
233 | `cz changelog` | Generate changelog | `cz ch` |
234 | `cz check` | Validate commit messages | - |
235 | `cz version` | Show version information | - |
236
237 ### Additional Resources
238
239 - [Conventional Commits Specification][conventional_commits]
240 - [Exit Codes Reference](https://commitizen-tools.github.io/commitizen/exit_codes/)
241 - [Configuration Guide](https://commitizen-tools.github.io/commitizen/config/configuration_file/)
242 - [Command Documentation](https://commitizen-tools.github.io/commitizen/commands/init/)
243
244 ### Getting Help
245
246 For each command, you can get detailed help by adding `--help`:
247
248 ```sh
249 cz commit --help
250 cz bump --help
251 cz changelog --help
252 ```
253
254 For more details, visit our [documentation site](https://commitizen-tools.github.io/commitizen/).
255
256 ## Setting up bash completion
257
258 Commitizen supports command-line completion through [argcomplete](https://kislyuk.github.io/argcomplete/), which is automatically installed as a dependency. This feature provides intelligent auto-completion for all Commitizen commands and options.
259
260 ### Supported Shells
261
262 - **Bash**: Full support
263 - **Zsh**: Limited support
264 - **Fish**: Limited support
265 - **Tcsh**: Limited support
266
267 ### Installation Methods
268
269 #### Global Installation (Recommended)
270
271 If you installed Commitizen globally (e.g., using `pipx` or `brew`), you can enable global completion:
272
273 ```bash
274 # Enable global completion for all Python applications
275 sudo activate-global-python-argcomplete
276 ```
277
278 #### User-Specific Installation
279
280 For a user-specific installation that persists across sessions:
281
282 ```bash
283 # Add to your shell's startup file (e.g., ~/.bashrc, ~/.zshrc)
284 register-python-argcomplete cz >> ~/.bashrc
285 ```
286
287 #### Temporary Installation
288
289 For one-time activation in your current shell session:
290
291 ```bash
292 # Activate completion for current session only
293 eval "$(register-python-argcomplete cz)"
294 ```
295
296 ### Verification
297
298 After installation, you can verify the completion is working by:
299
300 1. Opening a new terminal session
301 2. Typing `cz` followed by a space and pressing `TAB` twice
302 3. You should see a list of available commands
303
304 For more detailed information about argcomplete configuration and troubleshooting, visit the [argcomplete documentation](https://kislyuk.github.io/argcomplete/).
305
306 ## Star History
307
308 [![Star History Chart](https://star-history.dera.page/svg?repos=commitizen-tools/commitizen)](https://star-history.dera.page/#commitizen-tools/commitizen)
309
310
311 ## Sponsors
312
313 These are our cool sponsors!
314
315 <!-- sponsors --><!-- sponsors -->
316
317 [conventional_commits]: https://www.conventionalcommits.org
318 [semver]: https://semver.org/
319 [keepchangelog]: https://keepachangelog.com/
320 [gitscm]: https://git-scm.com/downloads