Skip to content

Commit

Permalink
Fix pre-releases (#77)
Browse files Browse the repository at this point in the history
* Fix prereleases

* Just in case

* Update CHANGELOG
  • Loading branch information
Jake-Shadle committed Jan 24, 2024
1 parent 6b00070 commit f7c129a
Show file tree
Hide file tree
Showing 7 changed files with 1,081 additions and 246 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
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
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.

0 comments on commit f7c129a

Please sign in to comment.