Skip to content

Commit

Permalink
Revert "fix: tilde constraint"
Browse files Browse the repository at this point in the history
This reverts commit 070a3f8.
  • Loading branch information
shyim committed May 2, 2024
1 parent d9e1ec2 commit 6ce207b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
8 changes: 8 additions & 0 deletions version/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
21 changes: 0 additions & 21 deletions version/constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))
}

0 comments on commit 6ce207b

Please sign in to comment.