Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,46 @@ ignored_tag_formats = [
"v${major}.${minor}",
]
```

## Why does `cz bump` also change a dependency that has the same version as my project?

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.
If a dependency happens to use the same version string as your project, that line gets bumped too:

```toml title="pyproject.toml"
[tool.poetry]
version = "6.1.0"

[tool.poetry.dependencies]
smart-open = {version = ">=5.2.0,<6.1.0", extras = ["s3"]} # also becomes <6.2.0

[tool.commitizen]
version = "6.1.0"
version_files = ["pyproject.toml:version"]
```

There are two ways to avoid this.

### Option 1 (recommended): use a version provider

Let a [version provider](config/version_provider.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:

```toml title="pyproject.toml"
[tool.commitizen]
version_provider = "poetry" # or "pep621", "uv", "npm", "cargo", ...
```

See also the [PEP621 FAQ entry](#support-for-pep621) above.

### Option 2: anchor the `version_files` pattern

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:

```toml title="pyproject.toml"
[tool.commitizen]
version_files = ["pyproject.toml:^version"]
```

See [`version_files`](config/bump.md#version_files) for more details on the `file:pattern` syntax.
Loading