-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fixes #104: correctly parse id repr for Rust 1.78+ #106
Conversation
dbcd11f
to
50cd0d1
Compare
50cd0d1
to
bec3685
Compare
Working on macOS (Apple Silicon). |
Since this is probably breaking the CI for everyone who has stable testing, may I suggest merging this soon? |
Thanks, I'd really like a test by someone on windows though, since paths may be different there (notably slash vs backslash). |
// Rust >= 1.78. Oh boy. | ||
let mut temp = None; | ||
|
||
let mut slash_split = node.id.repr.split('/').peekable(); | ||
|
||
while let Some(subset) = slash_split.next() { | ||
// Continue until the last part of the path. | ||
if slash_split.peek().is_some() { | ||
continue; | ||
} | ||
|
||
// If there's no next slash separator, we've reached the end, and subset is | ||
// one of: | ||
// - aa#0.1.0 | ||
// - directory#aa@0.1.0 | ||
if subset.contains('@') { | ||
let mut hash_split = subset.split('#'); | ||
// Skip everything before the hash. | ||
hash_split.next(); | ||
// Now in the rest, take everything up to the @. | ||
temp = hash_split.next().and_then(|end| end.split('@').next()); | ||
} else { | ||
// Otherwise, take everything up to the #. | ||
temp = subset.split('#').next(); | ||
} | ||
} |
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.
Or you could use cargo_util_schemas::core::PackageIdSpec::parse and then extract the path from the URL. Then if we extend the PackageIdSpec
syntax, its just a dependency update away.
btw the spec for Specs is at https://doc.rust-lang.org/cargo/reference/pkgid-spec.html
You shouldn't need any platform-specific testing done. If the output of the old (opaque) id worked for you then extracting it should work here as well because they are both URLs and are platform-independent and you already had to be handling any platform-specific logic for the old id format. |
@epage Ah thanks for the information, I hadn't realized this was platform-independent. |
This updates to the new pkgid spec used after Rust 1.77.
Fixes #104.
Fixes #114.