Fix/cargo workspace deps version for publishing - #2017
Conversation
|
bba3019 to
9277972
Compare
…ommitizen-tools#2009) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When iterating workspace members in `CargoProvider.set_lock_version`, the code subscripted `package["version"]["workspace"]` inside a try/except block that only caught `NonExistentKey`. If a member's `Cargo.toml` declared a hardcoded version (`version = "x.y.z"`) instead of `version.workspace = true`, `package["version"]` was a tomlkit `String` and the subscript raised `TypeError: string indices must be integers, not 'str'`, which was not caught and propagated as a crash. Replace the exception-driven check with an `isinstance` type guard so the inheritance lookup only runs when `version` is an actual table. Fixes commitizen-tools#2001 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
….12.1,<3.8 (commitizen-tools#2021) Signed-off-by: dependabot[bot] <support@github.com>
…itizen-tools#2022) Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
…ols#2029) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
…ols#2037) Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
…=0.9.17,<0.13 (commitizen-tools#2039) Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Tim Hsiung <26526132+bearomorphism@users.noreply.github.com>
…tools#2059) Signed-off-by: dependabot[bot] <support@github.com>
cz init already treated prek as installed, but always ran `pre-commit install`, which raised FileNotFoundError when only prek was on PATH. Use the available installer, and ask when both exist. Fixes commitizen-tools#2018
If neither pre-commit nor prek is on PATH, skip the hook-type question instead of failing init. Users who want hooks can install a tool and retry.
The InitFailedError branch in _ask_hook_installer was flagged by codecov as the only uncovered line of the PR. Add a test where the installer is available during the hook-type question but disappears before the install step, so the guard is exercised instead of removed.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* ci: restore changelog updates Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * ci: configure changelog updates on bump Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
I checked the fix for #2001 proposed by pull request #2002 and preferred to keep the fix I'm proposing in that pull request. The merged fix introduces a regression, since the @bearomorphism @Lee-W @woile , do you know if a review of this pull request is planned? Until it's merged, it's not possible to publish to crates.io with commitizen in a Rust project with a workspace. To recall the objective of this PR, a project may have a Cargo.toml like this: [workspace]
members = ["members/*"]
resolver = "2"
[workspace.package]
edition = "2024"
version = "0.1.0"
[workspace.dependencies]
member-hello = { path = "members/hello" }And the Cargo.toml of the workspace member: [package]
name = "member-hello"
version.workspace = trueIn order to publish on crates.io ( [workspace.dependencies]
member-hello = { path = "members/hello", version = "0.1.0" }But this version is dynamically resolved (because the workspace member has
|
Description
This PR makes 2 things:
Regarding the second point, to provide more details, crates.io requires that each crate have a version specified in Cargo.toml. For projects that use a workspace, this means that all members using
version.workspace = truemust also have a version specified at theworkspace.dependencieslevel (the specified version must be the same as that ofworkspace.version).When performing a version bump, in addition to updating
workspace.version(in Cargo.toml) and the versions in Cargo.lock, we must also update the versions specified in Cargo.toml, since they are actually dynamically managed by Cargo viaversion.workspace = true.Projects such as
crate-ci/cargo-releaseorpksunkara/cargo-workspacesalso use the same processChecklist
Was generative AI tooling used to co-author this PR?
no
Code Changes
uv run poe alllocally to ensure this change passes linter check and tests