Skip to content

Commit b008e76

Browse files
authored
Merge pull request #2250 from CiiDyR/fix/constraint-comparisons
fix: correctly compare semver according to spec 2.0.0
2 parents 9d3366f + 1657cf7 commit b008e76

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

pkg/util/constraint/constraint.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package constraint
22

33
import (
44
"fmt"
5-
"reflect"
65
"regexp"
76
"sort"
87
"strings"
@@ -180,11 +179,6 @@ func parseSingle(v string) (*Constraint, error) {
180179

181180
func prereleaseCheck(v, c *Version) bool {
182181
switch vPre, cPre := v.Prerelease() != "", c.Prerelease() != ""; {
183-
case cPre && vPre:
184-
// A constraint with a pre-release can only match a pre-release version
185-
// with the same base segments.
186-
return reflect.DeepEqual(c.Segments64(), v.Segments64())
187-
188182
case !cPre && vPre:
189183
// OK
190184
case cPre && !vPre:

pkg/util/constraint/constraint_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ func TestConstraintCheck(t *testing.T) {
7272
{"~> 2.1.0-a", "2.2.0-alpha", false},
7373
{"> 2.0", "2.1.0-beta", true},
7474
{">= 2.1.0-a", "2.1.0-beta", true},
75-
{">= 2.1.0-a", "2.1.1-beta", false},
75+
{">= 2.1.0-a", "2.1.1-beta", true},
7676
{">= 2.0.0", "2.1.0-beta", true},
77+
{">= 2.0.0-beta.0", "2.0.0-beta.2", true},
78+
{">= 2.0.0-beta.0", "2.0.1-beta.0", true},
79+
{">= 2.0.1-beta.0", "2.0.0-beta.0", false},
7780
{">= 2.1.0-a", "2.1.1", true},
78-
{">= 2.1.0-a", "2.1.1-beta", false},
7981
{">= 2.1.0-a", "2.1.0", true},
8082
{"<= 2.1.0-a", "2.0.0", true},
8183
}

0 commit comments

Comments
 (0)