Skip to content

Commit

Permalink
Allow requests for "3.10" to be compat with "3.10.10"
Browse files Browse the repository at this point in the history
Even when "3.10.10" has "x.x.x" compat.

Fixes #1030.

Signed-off-by: J Robert Ray <jrray@jrray.org>
  • Loading branch information
jrray committed May 30, 2024
1 parent ffb0306 commit 42225fd
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 42225fd

Please sign in to comment.