-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: Sparse URLs in TomlLockfileSourceId
#15990
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
Conversation
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.
Thanks! Would it be possible to add some tests around this?
I've added some unit tests for this. Let me know if there are other changes that you'd like me to make. |
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.
Thanks!
I think this change makes sense for cargo-util-schemas. This bug didn’t affect Cargo itself because we handled it when constructing the source ID.
It would be great if we could introduce an end-to-end test to verify that Cargo itself correctly handles this prefix, but I think it’s fine to add that in a separate PR.
Maybe something like:
let _registry = registry::RegistryBuilder::new()
.http_index()
.alternative()
.build();
Package::new("two-ver", "0.1.0").alternative(true).publish();
Package::new("two-ver", "0.2.0").alternative(true).publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[dependencies]
two-ver = { registry = 'alternative', version = "0.1.0" }
two-ver2 = { registry = 'alternative', package = "two-ver", version = "0.2.0" }
"#,
)
.file("src/lib.rs", "")
.file("cratesio", "")
.build();
p.cargo("generate-lockfile").run();
let lockfile = p.read_lockfile();
// TODO: check source ID URL here.
assert_eq!("", lockfile);
I thought cargo already had one. cargo/tests/testsuite/alt_registry.rs Lines 1768 to 1816 in 1c714ca
That being said, this change is also a fix for the I don't think adding an end-to-end test is going to cover this problem. |
Good catch! I didn't find it last night.
I am not saying it's gonna cover this issue from cargo-util-schema. That's also why we should add a test for Cargo itself in a separate PR.(The one you post in your comment) Thank you! I think this PR is ready to go. |
- Includes rust-lang/cargo#15980 - Includes rust-lang/cargo#15990
What does this PR try to resolve?
Sparse registries have their IDs prefixed with their kind (sparse+). This PR fixes the current implementation of
TomlLockfileSourceId
where it incorrectly splits the kind and URL for sparse registries.This change itself shouldn't affect cargo. It does, however, affect users of
cargo-util-schemas
, i.e. cargo plumbing commands. See crate-ci/cargo-plumbing#111How to test and review this PR?
Verify how source IDs are made, especially their URLs.