Skip to content

Commit b00c86a

Browse files
VamikaSinghalclaude
authored andcommitted
docs(faq): explain how to avoid bumping dependencies that share the project version
Closes #819 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2ebac02 commit b00c86a

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

‎docs/faq.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,46 @@ ignored_tag_formats = [
8989
"v${major}.${minor}",
9090
]
9191
```
92+
93+
## Why does `cz bump` also change a dependency that has the same version as my project?
94+
95+
When an entry in [`version_files`](config/bump.md#version_files) has no pattern, or a loose one, Commitizen replaces the current version on every line that matches it.
96+
If a dependency happens to use the same version string as your project, that line gets bumped too:
97+
98+
```toml title="pyproject.toml"
99+
[tool.poetry]
100+
version = "6.1.0"
101+
102+
[tool.poetry.dependencies]
103+
smart-open = {version = ">=5.2.0,<6.1.0", extras = ["s3"]} # also becomes <6.2.0
104+
105+
[tool.commitizen]
106+
version = "6.1.0"
107+
version_files = ["pyproject.toml:version"]
108+
```
109+
110+
There are two ways to avoid this.
111+
112+
### Option 1 (recommended): use a version provider
113+
114+
Let a [version provider](config/version_provider.md) update the version field directly instead of listing the file in `version_files`.
115+
Providers edit the exact key (for example `tool.poetry.version` or `project.version`), so dependencies are never touched:
116+
117+
```toml title="pyproject.toml"
118+
[tool.commitizen]
119+
version_provider = "poetry" # or "pep621", "uv", "npm", "cargo", ...
120+
```
121+
122+
See also the [PEP621 FAQ entry](#support-for-pep621) above.
123+
124+
### Option 2: anchor the `version_files` pattern
125+
126+
The part after the colon in a `version_files` entry is a regular expression, matched against each line.
127+
Anchor it with `^` so only lines that *start* with `version` are updated:
128+
129+
```toml title="pyproject.toml"
130+
[tool.commitizen]
131+
version_files = ["pyproject.toml:^version"]
132+
```
133+
134+
See [`version_files`](config/bump.md#version_files) for more details on the `file:pattern` syntax.

0 commit comments

Comments
 (0)