You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 14355aa
Browse filesBrowse the repository at this point in the historyBrowse files
<h2id="why-does-cz-bump-also-change-a-dependency-that-has-the-same-version-as-my-project">Why does <code>cz bump</code> also change a dependency that has the same version as my project?<aclass="headerlink" href="#why-does-cz-bump-also-change-a-dependency-that-has-the-same-version-as-my-project" title="Permanent link">¶</a></h2>
2342
+
<p>When an entry in <ahref="../config/bump/#version_files"><code>version_files</code></a> has no pattern, or a loose one, Commitizen replaces the current version on every line that matches it.
2343
+
If a dependency happens to use the same version string as your project, that line gets bumped too:</p>
<spanclass="n">smart-open</span><spanclass="w"></span><spanclass="o">=</span><spanclass="w"></span><spanclass="p">{</span><spanclass="n">version</span><spanclass="w"></span><spanclass="p">=</span><spanclass="w"></span><spanclass="s2">">=5.2.0,<6.1.0"</span><spanclass="p">,</span><spanclass="w"></span><spanclass="n">extras</span><spanclass="w"></span><spanclass="p">=</span><spanclass="w"></span><spanclass="p">[</span><spanclass="s2">"s3"</span><spanclass="p">]}</span><spanclass="w"></span><spanclass="c1"># also becomes <6.2.0</span>
<h3id="option-1-recommended-use-a-version-provider">Option 1 (recommended): use a version provider<aclass="headerlink" href="#option-1-recommended-use-a-version-provider" title="Permanent link">¶</a></h3>
2356
+
<p>Let a <ahref="../config/version_provider/">version provider</a> update the version field directly instead of listing the file in <code>version_files</code>.
2357
+
Providers edit the exact key (for example <code>tool.poetry.version</code> or <code>project.version</code>), so dependencies are never touched:</p>
Copy file name to clipboardExpand all lines: faq/index.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,3 +86,49 @@ ignored_tag_formats = [
86
86
"v${major}.${minor}",
87
87
]
88
88
```
89
+
90
+
## Why does `cz bump` also change a dependency that has the same version as my project?
91
+
92
+
When an entry in [`version_files`](https://commitizen-tools.github.io/commitizen/config/bump/#version_files) has no pattern, or a loose one, Commitizen replaces the current version on every line that matches it. If a dependency happens to use the same version string as your project, that line gets bumped too:
### Option 1 (recommended): use a version provider
111
+
112
+
Let a [version provider](https://commitizen-tools.github.io/commitizen/config/version_provider/index.md) update the version field directly instead of listing the file in `version_files`. Providers edit the exact key (for example `tool.poetry.version` or `project.version`), so dependencies are never touched:
113
+
114
+
pyproject.toml
115
+
116
+
```
117
+
[tool.commitizen]
118
+
version_provider = "poetry" # or "pep621", "uv", "npm", "cargo", ...
119
+
```
120
+
121
+
See also the [PEP621 FAQ entry](#support-for-pep621) above.
122
+
123
+
### Option 2: anchor the `version_files` pattern
124
+
125
+
The part after the colon in a `version_files` entry is a regular expression, matched against each line. Anchor it with `^` so only lines that *start* with `version` are updated:
126
+
127
+
pyproject.toml
128
+
129
+
```
130
+
[tool.commitizen]
131
+
version_files = ["pyproject.toml:^version"]
132
+
```
133
+
134
+
See [`version_files`](https://commitizen-tools.github.io/commitizen/config/bump/#version_files) for more details on the `file:pattern` syntax.
Copy file name to clipboardExpand all lines: llms-full.txt
+46Lines changed: 46 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -406,6 +406,52 @@ ignored_tag_formats = [
406
406
]
407
407
```
408
408
409
+
## Why does `cz bump` also change a dependency that has the same version as my project?
410
+
411
+
When an entry in [`version_files`](https://commitizen-tools.github.io/commitizen/config/bump/#version_files) has no pattern, or a loose one, Commitizen replaces the current version on every line that matches it. If a dependency happens to use the same version string as your project, that line gets bumped too:
### Option 1 (recommended): use a version provider
430
+
431
+
Let a [version provider](https://commitizen-tools.github.io/commitizen/config/version_provider/index.md) update the version field directly instead of listing the file in `version_files`. Providers edit the exact key (for example `tool.poetry.version` or `project.version`), so dependencies are never touched:
432
+
433
+
pyproject.toml
434
+
435
+
```
436
+
[tool.commitizen]
437
+
version_provider = "poetry" # or "pep621", "uv", "npm", "cargo", ...
438
+
```
439
+
440
+
See also the [PEP621 FAQ entry](#support-for-pep621) above.
441
+
442
+
### Option 2: anchor the `version_files` pattern
443
+
444
+
The part after the colon in a `version_files` entry is a regular expression, matched against each line. Anchor it with `^` so only lines that *start* with `version` are updated:
445
+
446
+
pyproject.toml
447
+
448
+
```
449
+
[tool.commitizen]
450
+
version_files = ["pyproject.toml:^version"]
451
+
```
452
+
453
+
See [`version_files`](https://commitizen-tools.github.io/commitizen/config/bump/#version_files) for more details on the `file:pattern` syntax.
454
+
409
455
# Exit Codes
410
456
411
457
Commitizen handles expected exceptions through `CommitizenException` and returns different exit codes for different situations. This reference is useful when you need to ignore specific errors in your CI/CD pipeline or automation scripts.
0 commit comments