Skip to content

Commit fb17a02

Browse files
authored
Merge pull request #142 from mattfarina/fix-141
Fixed issue with <= comparison
2 parents fa79876 + f1b17e8 commit fb17a02

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

constraints.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func constraintLessThanEqual(v *Version, c *constraint) bool {
401401

402402
if v.Major() > c.con.Major() {
403403
return false
404-
} else if v.Minor() > c.con.Minor() && !c.minorDirty {
404+
} else if v.Major() == c.con.Major() && v.Minor() > c.con.Minor() && !c.minorDirty {
405405
return false
406406
}
407407

constraints_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ func TestConstraintsCheck(t *testing.T) {
310310
{"<=2.x", "3.0.0", false},
311311
{"<=1.1", "1.1.1", true},
312312
{"<=1.1.x", "1.2.500", false},
313+
{"<=4.5", "3.4.0", true},
314+
{"<=4.5", "3.7.0", true},
315+
{"<=4.5", "4.6.3", false},
313316
{">1.1, <2", "1.1.1", false},
314317
{">1.1, <2", "1.2.1", true},
315318
{">1.1, <3", "4.3.2", false},
@@ -349,6 +352,7 @@ func TestConstraintsCheck(t *testing.T) {
349352
{">= 1.1 < 2 !=1.2.3 || > 3", "3.0.0", false},
350353
{">=1.1 < 2 !=1.2.3 || > 3", "1.2.3", false},
351354
{"1.1 - 2", "1.1.1", true},
355+
{"1.5.0 - 4.5", "3.7.0", true},
352356
{"1.1-3", "4.3.2", false},
353357
{"^1.1", "1.1.1", true},
354358
{"^1.1", "4.3.2", false},

0 commit comments

Comments
 (0)