Description
The pull request #1402 added the version update of Cargo.lock, which is indeed necessary.
However, the implementation of the workspace feature of cargo is wrong and can lead to crash when bumping the version.
Steps to reproduce
- Create a rust project (
cargo init)
- Replace the
[package] by a workspace (rewrite Cargo.toml) :
[workspace]
members = ["whatever"]
resolver = "2"
[worspace.package]
description = ""
edition = "2024"
license = ""
version = "0.1.0"
- Create a
whatever crate (cargo new whatever)
cz init
git add . && git commit -m "feat: first commit"
cz bump --yes
Current behavior
Right now, the code expects the workspace to have a "name" key, which is not a standard workspace key. A crash occurs if the Cargo.toml doesn't have a [package] but has a [workspace.package] without a "name" key.
Desired behavior
The code should not expect any "name" key. Instead, when a workspace is used, it should :
- read members
- resolve potential glob
- for each workspace member, check the Cargo.toml. If it contains the "version.workspace = true" line, this means the version is inherited from the workspace version and should be changed in the Cargo.lock
Screenshots
No response
Environment
Commitizen Version: 4.8.3
Python Version: 3.12.3
Operating System: Linux
Description
The pull request #1402 added the version update of Cargo.lock, which is indeed necessary.
However, the implementation of the workspace feature of cargo is wrong and can lead to crash when bumping the version.
Steps to reproduce
cargo init)[package]by a workspace (rewriteCargo.toml) :whatevercrate (cargo new whatever)cz initgit add . && git commit -m "feat: first commit"cz bump --yesCurrent behavior
Right now, the code expects the workspace to have a "name" key, which is not a standard workspace key. A crash occurs if the
Cargo.tomldoesn't have a[package]but has a[workspace.package]without a "name" key.Desired behavior
The code should not expect any "name" key. Instead, when a workspace is used, it should :
Screenshots
No response
Environment
Commitizen Version: 4.8.3
Python Version: 3.12.3
Operating System: Linux