Title: fix(cargo_provider): support workspace virtual manifests by jcfangc · Pull Request #1733 · commitizen-tools/commitizen · GitHub
Open Graph Title: fix(cargo_provider): support workspace virtual manifests by jcfangc · Pull Request #1733 · commitizen-tools/commitizen
X Title: fix(cargo_provider): support workspace virtual manifests by jcfangc · Pull Request #1733 · commitizen-tools/commitizen
Description: Description Fix cargo_provider so cz bump works with Cargo workspace virtual manifests (root Cargo.toml containing [workspace] / [workspace.package] but no [package]) when workspace members inherit the version via package.version.workspace = true. Previously, cz bump could crash in commitizen/providers/cargo_provider.py with: NonExistentKey: Key "package" does not exist (virtual manifest has no [package]) TypeError: expected root version to be a string / unsafe assumptions around package.version shape This change makes the provider: Read/write the version from [workspace.package].version when present (fallback to [package].version for non-workspace manifests). When updating Cargo.lock: For non-workspace manifests, update the root package entry. For workspace virtual manifests, scan workspace.members (respecting exclude) and update lock entries for crates that declare package.version.workspace = true. Fixes #1732 Checklist I have read the contributing guidelines Added test coverage for the introduced behavior and edge cases Ran the test suite locally Manually tested the behavior (workspace virtual manifest + non-workspace crate) Updated documentation (not needed for this change) Note: the project uses uv / poe tasks (not Poetry). I ran the equivalent poe / uv-based test commands. Expected Behavior cz bump with version_provider = "cargo" should succeed for Cargo workspaces using a virtual manifest and centralized versioning in [workspace.package].version, without crashing. The workspace version should be updated, and Cargo.lock entries for crates inheriting the workspace version (package.version.workspace = true) should be updated safely. Non-workspace projects (root [package]) keep existing behavior. Steps to Test This Pull Request Manual test (workspace virtual manifest) Create a workspace root Cargo.toml: [workspace] members = ["crates/*"] [workspace.package] version = "1.0.0" edition = "2024" rust-version = "1.92" repository = "https://example.com/repo.git" Add a member crate crates/common-core/Cargo.toml: [package] name = "common-core" version.workspace = true edition.workspace = true rust-version.workspace = true repository.workspace = true Generate Cargo.lock once: cargo build Configure Commitizen: [tool.commitizen] name = "cz_conventional_commits" tag_format = "v$version" version_scheme = "semver" version_provider = "cargo" update_changelog_on_bump = true version_files = ["Cargo.toml:workspace.package.version"] Run: cz bump --yes Verify: [workspace.package].version is updated (e.g., 1.0.0 -> 1.1.0) Cargo.lock entries for workspace crates inheriting the version are updated no exceptions are raised Manual test (non-workspace manifest) Use a standard crate with root [package] and an existing Cargo.lock. Run cz bump --yes and verify the root package version in Cargo.lock is updated as before. Additional Context Reported in #1732. Targets workspace virtual manifests (no root [package]) and avoids unsafe assumptions about the TOML shape of version fields.
Open Graph Description: Description Fix cargo_provider so cz bump works with Cargo workspace virtual manifests (root Cargo.toml containing [workspace] / [workspace.package] but no [package]) when workspace members inherit...
X Description: Description Fix cargo_provider so cz bump works with Cargo workspace virtual manifests (root Cargo.toml containing [workspace] / [workspace.package] but no [package]) when workspace members inherit...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1733
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:69771310-f157-c81f-4cd6-96639252748d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BD38:14FB0B:A9447D4:DB6623A:69765FD7 |
| html-safe-nonce | a10035544ea4c3b0bc280a147f3fd2880bed6faeb128d7f4bc6934eb3ea51803 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDM4OjE0RkIwQjpBOTQ0N0Q0OkRCNjYyM0E6Njk3NjVGRDciLCJ2aXNpdG9yX2lkIjoiNTk3NjAwNjE0MTUzMDIzNDg0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 09af7a73fb050273cdab773c87831dc1a6709a62048da8f183f1a594ba37c02d |
| hovercard-subject-tag | pull_request:3124839433 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1733/files |
| twitter:image | https://avatars.githubusercontent.com/u/111571686?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/111571686?s=400&v=4 |
| og:image:alt | Description Fix cargo_provider so cz bump works with Cargo workspace virtual manifests (root Cargo.toml containing [workspace] / [workspace.package] but no [package]) when workspace members inherit... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 032152924a283b83384255d9489e7b93b54ba01da8d380b05ecd3953b3212411 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5b577f6be6482e336e3c30e8daefa30144947b17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width