Skip to content

publish: Normalize dependency version requirements #7245

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

Merged
merged 2 commits into from
Oct 6, 2023

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Oct 6, 2023

When cargo reads a Cargo.toml file and sees a foo = "1.0" dependency declaration it saves the version requirement as a semver::VersionReq. If cargo then publishes the crate and transforms the dependency declaration to the publish metadata JSON blob it essentially uses semver::VersionReq::to_string() which normalizes the version requirement and transforms 1.0 into ^1.0.

On the crates.io side we've been accepting these values from the metadata as-is and only using VersionReq::parse() to check if it is a valid version requirement, but there was no normalization performed.

Since we now read dependency declarations directly from the embedded Cargo.toml file ourselves (see #7238) the normalization that cargo (unintentionally?) performed is now missing.

This PR brings back the normalization with a VersionReq::parse() and to_string() cycle.

@Turbo87 Turbo87 added C-bug 🐞 Category: unintended, undesired behavior A-backend ⚙️ labels Oct 6, 2023
@Turbo87 Turbo87 merged commit 3d5ad6e into rust-lang:main Oct 6, 2023
@Turbo87 Turbo87 deleted the normalize-version-req branch October 6, 2023 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-bug 🐞 Category: unintended, undesired behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant