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

Fix pre-releases #77

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Fixed
- [PR#77](https://github.com/EmbarkStudios/krates/pull/77) resolved [#76](https://github.com/EmbarkStudios/krates/issues/76) by special casing "wildcard" version requirements if the version being tested is a pre-release, as pre-releases must have at least one comparator.

## [0.16.5] - 2024-01-24
### Fixed
- [PR#75](https://github.com/EmbarkStudios/krates/pull/75) resolved [#74](https://github.com/EmbarkStudios/krates/issues/74) by just always checking version requirements for dependencies. Sigh.
Expand Down
10 changes: 8 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,9 @@ impl Builder {
// mean there could be a situation where a single crate _could_
// be referenced with 0.0.x versions, but...I'll fix that if
// someone reports an issue
let rdep_version = rdep.pkg.version().parse().expect("failed to parse semver");
let rdep_version: semver::Version =
rdep.pkg.version().parse().expect("failed to parse semver");
let has_prelease = !rdep_version.pre.is_empty();

let edges = rdep.dep_kinds.iter().filter_map(|dk| {
let mask = match dk.kind {
Expand Down Expand Up @@ -1178,7 +1180,11 @@ impl Builder {
return false;
}

dep.req.matches(&rdep_version)
// Handle case where a dependency may not have a version requirement, which
// typically happens in the case of non-registry dependencies that use a pre-release
// semver, if the version _is_ a prelease it will never match the empty
// requirement
(has_prelease && dep.req.comparators.is_empty()) || dep.req.matches(&rdep_version)
})
.unwrap_or_else(|| panic!("cargo metadata resolved a dependency for a dependency not specified by the crate: {rdep:?}"));

Expand Down
2 changes: 1 addition & 1 deletion tests/pid-opaque.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/pid-stable.json

Large diffs are not rendered by default.