-
-
Notifications
You must be signed in to change notification settings - Fork 312
fix(cargo_provider): support workspace virtual manifests #1733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cargo_provider): support workspace virtual manifests #1733
Conversation
bearomorphism
commented
Dec 26, 2025
Hi @jcfangc ,
Thank you for your contribution! Please follow the contribution guideline. You forget to run poetry format on the latest iteration.
jcfangc
commented
Dec 31, 2025
Hi @jcfangc , Thank you for your contribution! Please follow the contribution guideline. You forget to run
poetry formaton the latest iteration.
Sorry about that—I’ll run poetry format and push an update asap.
Codecov Report
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.98%. Comparing base (aa82b98) to head (0eead00).
✅ All tests successful. No failed tests found.
Additional details and impacted files
@@ Coverage Diff @@ ## master #1733 +/- ## ========================================== + Coverage 97.95% 97.98% +0.02% ========================================== Files 60 60 Lines 2646 2674 +28 ========================================== + Hits 2592 2620 +28 Misses 54 54
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
jcfangc
commented
Jan 4, 2026
When I first pulled the branch locally, I didn’t have uv.lock in the working tree, and poetry format isn’t a Poetry subcommand in my setup (Poetry 1.1.12 reports: "The command 'format' is not defined").
Following the repo’s uv/poe workflow, I synced dependencies (needed uv sync --all-groups to make ruff available), then ran uv run poe format, and pushed the formatting update.
Just to clarify / FYI.
noirbizarre
commented
Jan 5, 2026
I think it would be easier and cleaner to just rebase/squash on the current master.
You are not changing dependencies, so your PR should not touch the uv.lock file.
To avoid this side effect, run uv sync --frozen --all-groups instead of just uv sync --all-groups (uv default behavior is to check and update the lock).
Also, you might want to update your uv version, it is trying to downgrade the lock version so it might be outdated.
a933a55 to
c932fc0
Compare
jcfangc
commented
Jan 5, 2026
I think it would be easier and cleaner to just rebase/squash on the current master. You are not changing dependencies, so your PR should not touch the
uv.lockfile. To avoid this side effect, runuv sync --frozen --all-groupsinstead of justuv sync --all-groups(uvdefault behavior is to check and update the lock). Also, you might want to update youruvversion, it is trying to downgrade the lock version so it might be outdated.
Thanks for the feedback.
I’ve rebased/squashed the branch on top of the current master and ensured the PR no longer touches lockfiles:
- reverted/restored
uv.lockandpoetry.lockto matchmaster(no lockfile changes in the PR diff now)
Going forward I’ll use uv sync --frozen --all-groups to avoid accidental lock updates, and I’ll also update my local uv to prevent lock format/version downgrades.
All checks are now green.
woile
commented
Jan 5, 2026
The rebase did not succeed, only your commits should appear on "Commits".
On top of that, I wonder if #1715 (in-progress) addresses this issue, can you take a look? It also changes the read order, if there are no complaints about that I was planning on merging it
jcfangc
commented
Jan 5, 2026
The rebase did not succeed, only your commits should appear on "Commits".
On top of that, I wonder if #1715 (in-progress) addresses this issue, can you take a look? It also changes the read order, if there are no complaints about that I was planning on merging it
Hi @woile, thanks for flagging #1715 — they are related but not the same.
-
fix: workspace member with fixed version #1715 focuses on two smaller cargo-provider behaviors:
- ensuring we use the same precedence/order when reading vs writing the version between
[package]and workspace metadata, and - clarifying/fixing the "fixed version for a workspace member" case: there is no
workspace.version = "x.y.z"in Cargo spec; a member crate must useversion = "x.y.z"even if it’s part of a workspace.
- ensuring we use the same precedence/order when reading vs writing the version between
-
fix(cargo_provider): support workspace virtual manifests #1733 targets a broader and different failure mode: workspace virtual manifests (root
Cargo.tomlwith[workspace]/[workspace.package]but no[package]). It:- prevents crashes when
[package]is missing / whenversion.workspaceshape appears, - reads/writes version from
[workspace.package].versionwhen present (fallback to[package].versionfor non-workspace manifests), and - updates
Cargo.lockappropriately for virtual manifests by scanningworkspace.membersand updating lock entries for crates withpackage.version.workspace = true.
- prevents crashes when
So #1715 does not address the virtual-manifest crash nor the lockfile update logic; #1733 does. The overlap is mostly around "precedence when both [package] and [workspace.package] exist", which is a policy choice.
If you’d like to merge #1715 first, I can rebase #1733 on top of it and drop any overlapping hunks/tests. Alternatively, I can incorporate the #1715 precedence decision into #1733 so we end up with a single coherent behavior.
d99d5af to
6bea1b9
Compare
The rebase did not succeed, only your commits should appear on "Commits".
On top of that, I wonder if #1715 (in-progress) addresses this issue, can you take a look? It also changes the read order, if there are no complaints about that I was planning on merging it
I rebuilt the branch on top of current upstream/master by cherry-picking only my 4 commits (no merge commits).
The PR no longer touches any lockfiles (uv.lock / poetry.lock).
Could you please take another look? @woile
@bearomorphism
bearomorphism
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! Here are some feedbacks:
07c23f5 to
3d11e37
Compare
8bad439 to
df118dc
Compare
jcfangc
commented
Jan 7, 2026
Hi @bearomorphism @woile @noirbizarre @Lee-W — I’ve addressed the requested changes and force-pushed updates.
- Fixed the review comments in
cargo_provider.py, hardened parsing/lock updates, removed an unusedtype: ignore, and ran the formatter. - No
uv.lock/poetry.lockchanges; all checks are green.
Could you please re-review when you have a moment? Thanks.
b46a08c to
5327c04
Compare
- prefer [workspace.package] version with safe fallback to [package] - handle virtual workspace + version.workspace=true members when updating Cargo.lock - add regression tests for error/continue branches and workspace edge cases
5327c04 to
0eead00
Compare
Uh oh!
There was an error while loading. Please reload this page.
Description
Fix
cargo_providersocz bumpworks with Cargo workspace virtual manifests (rootCargo.tomlcontaining[workspace]/[workspace.package]but no[package]) when workspace members inherit the version viapackage.version.workspace = true.Previously,
cz bumpcould crash incommitizen/providers/cargo_provider.pywith:NonExistentKey: Key "package" does not exist(virtual manifest has no[package])TypeError: expected root version to be a string/ unsafe assumptions aroundpackage.versionshapeThis change makes the provider:
Read/write the version from
[workspace.package].versionwhen present (fallback to[package].versionfor non-workspace manifests).When updating
Cargo.lock:workspace.members(respectingexclude) and update lock entries for crates that declarepackage.version.workspace = true.Fixes #1732
Checklist
Expected Behavior
cz bumpwithversion_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, andCargo.lockentries 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:Add a member crate
crates/common-core/Cargo.toml:Generate
Cargo.lockonce:Configure Commitizen:
Run:
Verify:
[workspace.package].versionis updated (e.g.,1.0.0 -> 1.1.0)Cargo.lockentries for workspace crates inheriting the version are updatedManual test (non-workspace manifest)
[package]and an existingCargo.lock.cz bump --yesand verify the root package version inCargo.lockis updated as before.Additional Context
[package]) and avoids unsafe assumptions about the TOML shape of version fields.