Skip to content

Commit

Permalink
Merge pull request #1033 from imageworks/jrray/issue1030
Browse files Browse the repository at this point in the history
Allow requests for "3.10" to be compat with "3.10.10"
  • Loading branch information
jrray authored Jun 3, 2024
2 parents 00531b8 + 42225fd commit c38eeee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/spk-schema/crates/foundation/src/version/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ impl Compat {
for (i, rule) in self.parts.iter().enumerate() {
let a = base.parts.get(i);
let b = other.parts.get(i);

if a.is_none() {
// Handle case where "3.10" is specified and other is "3.10.10".
// Since 3 == 3 and 10 == 10 and no other version parts are
// specified, we consider these compatible.
return Compatibility::Compatible;
}

if rule.0.contains(&CompatRule::None) {
match (a, b) {
(Some(a), Some(b)) if a != b => {
Expand Down
2 changes: 2 additions & 0 deletions crates/spk-schema/src/version_range_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ fn test_version_range_is_satisfied_recipe(
#[case("Binary:1.38.0", spec!({"pkg": "test/1.38.0+r.3/JRSXNRF4", "compat": "x.x.x+ab"}), true)]
// smaller numbers are not compatible
#[case("Binary:5.12.2.1", spec!({"pkg": "test/5.12.2/JRSXNRF4", "compat": "x.x.ab"}), false)]
// asking for "3.10" is expected to allow "3.10.10"
#[case::under_specified_version_and_x_compat("API:3.10", spec!({"pkg": "test/3.10.10/JRSXNRF4", "compat": "x.x.x"}), true)]
fn test_version_range_is_satisfied_spec(
#[case] range: &str,
#[case] spec: Spec,
Expand Down

0 comments on commit c38eeee

Please sign in to comment.