We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7f96b0d + 6d097ca commit 0873dd6Copy full SHA for 0873dd6
.travis.yml
@@ -5,6 +5,7 @@ language: go
5
go:
6
- 1.11.x
7
- 1.12.x
8
+ - 1.13.x
9
- tip
10
11
# Setting sudo access to false will let Travis CI use containers rather than
constraints.go
@@ -478,19 +478,29 @@ func constraintCaret(v *Version, c *constraint) bool {
478
return false
479
}
480
481
+ // This less than handles prereleases
482
if v.LessThan(c.con) {
483
484
485
- if (c.con.Major() > 0 || c.minorDirty) && v.Major() == c.con.Major() {
486
- return true
487
- } else if (c.con.Minor() > 0 || c.patchDirty) && v.Minor() == c.con.Minor() {
488
489
- } else if v.Patch() == c.con.Patch() {
490
+ // ^ when the major > 0 is >=x.y.z < x+1
+ if c.con.Major() > 0 || c.minorDirty {
+
+ // ^ has to be within a major range for > 0. Everything less than was
+ // filtered out with the LessThan call above. This filters out those
491
+ // that greater but not within the same major range.
492
+ return v.Major() == c.con.Major()
493
494
- return false
495
+ // ^ when the major is 0 and minor > 0 is >=0.y.z < 0.y+1
496
+ // If the con Minor is > 0 it is not dirty
497
+ if c.con.Minor() > 0 || c.patchDirty {
498
+ return v.Minor() == c.con.Minor()
499
+ }
500
501
+ // At this point the major is 0 and the minor is 0 and not dirty. The patch
502
+ // is not dirty so we need to check if they are equal. If they are not equal
503
+ return c.con.Patch() == v.Patch()
504
505
506
func isX(x string) bool {
constraints_test.go
@@ -152,6 +152,13 @@ func TestConstraintCheck(t *testing.T) {
152
{"~1.2.3-beta.2", "1.3.4-beta.2", false},
153
{"^1.2.3", "1.8.9", true},
154
{"^1.2.3", "2.8.9", false},
155
+ {"^1.2.3", "1.2.1", false},
156
+ {"^1.1.0", "2.1.0", false},
157
+ {"^1.2.0", "2.2.1", false},
158
+ {"^1.2.0", "1.2.1-alpha.1", false},
159
+ {"^1.2.0-alpha.0", "1.2.1-alpha.1", true},
160
+ {"^1.2.0-alpha.0", "1.2.1-alpha.0", true},
161
+ {"^1.2.0-alpha.2", "1.2.0-alpha.1", false},
162
{"^1.2", "1.8.9", true},
163
{"^1.2", "2.8.9", false},
164
{"^1", "1.8.9", true},
@@ -174,6 +181,7 @@ func TestConstraintCheck(t *testing.T) {
174
181
// following semver.
175
182
{"^0.2.3-beta.2", "0.2.4-beta.2", true},
176
183
{"^0.2.3-beta.2", "0.3.4-beta.2", false},
184
+ {"^0.2.3-beta.2", "0.2.3-beta.2", true},
177
185
178
186
179
187
for _, tc := range tests {
0 commit comments