From 1b4e5a26d9da25a8c2a5fd1846817c62092f8646 Mon Sep 17 00:00:00 2001 From: Kyle Michel Date: Sat, 2 Nov 2019 21:15:50 -0400 Subject: [PATCH] Fixing broken constraint checking with ^0.0 --- constraints.go | 3 +++ constraints_test.go | 1 + 2 files changed, 4 insertions(+) diff --git a/constraints.go b/constraints.go index 548e843..d57ec62 100644 --- a/constraints.go +++ b/constraints.go @@ -493,6 +493,9 @@ func constraintCaret(v *Version, c *constraint) bool { } // ^ when the major is 0 and minor > 0 is >=0.y.z < 0.y+1 + if c.con.Major() == 0 && v.Major() > 0 { + return false + } // If the con Minor is > 0 it is not dirty if c.con.Minor() > 0 || c.patchDirty { return v.Minor() == c.con.Minor() diff --git a/constraints_test.go b/constraints_test.go index b5bb562..f6be534 100644 --- a/constraints_test.go +++ b/constraints_test.go @@ -171,6 +171,7 @@ func TestConstraintCheck(t *testing.T) { {"^0.0.3", "0.0.4", false}, {"^0.0", "0.0.3", true}, {"^0.0", "0.1.4", false}, + {"^0.0", "1.0.4", false}, {"^0", "0.2.3", true}, {"^0", "1.1.4", false}, {"^0.2.3-beta.2", "0.2.3-beta.4", true},