From 6ce207b0c4a43775064916dd3d70c54925769a9c Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 2 May 2024 14:51:47 +0200 Subject: [PATCH] Revert "fix: tilde constraint" This reverts commit 070a3f8ff4d94d2d03ec1e61916e2bfb3a07da8f. --- version/constraint.go | 8 ++++++++ version/constraint_test.go | 21 --------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/version/constraint.go b/version/constraint.go index 09c7636..3422e12 100644 --- a/version/constraint.go +++ b/version/constraint.go @@ -274,6 +274,14 @@ func constraintTilde(v, c *Version) bool { return false } + if v.segments[1] != c.segments[1] && c.si > 1 { + return false + } + + if reflect.DeepEqual(v.segments, c.segments) && !prereleaseCheck(v, c) { + return false + } + return true } diff --git a/version/constraint_test.go b/version/constraint_test.go index 26b9c6b..6704cf9 100644 --- a/version/constraint_test.go +++ b/version/constraint_test.go @@ -48,24 +48,3 @@ func TestConstraintVersionNumber(t *testing.T) { assert.True(t, c.Check(Must(NewVersion("1.0.0")))) assert.False(t, c.Check(Must(NewVersion("1.0.1")))) } - -func TestTildeConstraintPositive(t *testing.T) { - assert.True(t, MustConstraints(NewConstraint("~2.4")).Check(Must(NewVersion("2.9.0")))) - assert.True(t, MustConstraints(NewConstraint("~2.4")).Check(Must(NewVersion("2.4.5")))) - - assert.True(t, MustConstraints(NewConstraint("~1")).Check(Must(NewVersion("1.2.3")))) - assert.True(t, MustConstraints(NewConstraint("~1.0")).Check(Must(NewVersion("1.4.7")))) - - assert.True(t, MustConstraints(NewConstraint("~1.2.1 >=1.2.3")).Check(Must(NewVersion("1.2.3")))) - assert.True(t, MustConstraints(NewConstraint("~1.2.1 =1.2.3")).Check(Must(NewVersion("1.2.3")))) - assert.True(t, MustConstraints(NewConstraint("~1.2.1 1.2.3")).Check(Must(NewVersion("1.2.3")))) - assert.True(t, MustConstraints(NewConstraint("~1.2.1 >=1.2.3 1.2.3")).Check(Must(NewVersion("1.2.3")))) - assert.True(t, MustConstraints(NewConstraint("~1.2.1 1.2.3 >=1.2.3")).Check(Must(NewVersion("1.2.3")))) - assert.True(t, MustConstraints(NewConstraint("~1.2.1 1.2.3")).Check(Must(NewVersion("1.2.3")))) -} - -func TestTildeConstraintNegative(t *testing.T) { - assert.False(t, MustConstraints(NewConstraint("~2.4")).Check(Must(NewVersion("3.0.0")))) - assert.False(t, MustConstraints(NewConstraint("~2.4")).Check(Must(NewVersion("2.3.9")))) - assert.False(t, MustConstraints(NewConstraint("~1")).Check(Must(NewVersion("0.2.3")))) -}