Skip to content
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

Merged
merged 4 commits into from
Mar 24, 2024

Conversation

bnjbvr
Copy link
Owner

@bnjbvr bnjbvr commented Feb 12, 2024

This updates to the new pkgid spec used after Rust 1.77.

Fixes #104.
Fixes #114.

@utkarshgupta137
Copy link

Working on macOS (Apple Silicon).

@utkarshgupta137
Copy link

Since this is probably breaking the CI for everyone who has stable testing, may I suggest merging this soon?

@bnjbvr
Copy link
Owner Author

bnjbvr commented Mar 21, 2024

Thanks, I'd really like a test by someone on windows though, since paths may be different there (notably slash vs backslash).

Comment on lines +369 to +394
// 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();
}
}
Copy link

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

@epage
Copy link

epage commented Mar 22, 2024

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.

@bnjbvr
Copy link
Owner Author

bnjbvr commented Mar 24, 2024

@epage Ah thanks for the information, I hadn't realized this was platform-independent.

@bnjbvr bnjbvr merged commit 3df0250 into main Mar 24, 2024
3 checks passed
@bnjbvr bnjbvr deleted the fix-node-id-repr-nightly branch March 24, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Rust 1.77.0] cargo machete --with-metadata panicking Investigate Nightly CI failure
3 participants