From a0855541e2d79897596aa68db634b2de1b460109 Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Thu, 3 Aug 2017 13:18:19 -0500 Subject: [PATCH 1/2] Use fork of Masterminds/semver until PR is merged Use fix from https://github.com/Masterminds/semver/issues/60 --- Gopkg.lock | 7 ++++--- Gopkg.toml | 3 ++- .../github.com/Masterminds/semver/constraints.go | 2 +- .../Masterminds/semver/constraints_test.go | 15 ++++++++++++++- vendor/github.com/Masterminds/semver/parse.go | 3 +++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 67b2284ca4..5278bfd612 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,10 +2,11 @@ [[projects]] - branch = "2.x" + branch = "parse-constraints-with-dash-in-pre" name = "github.com/Masterminds/semver" packages = ["."] - revision = "139cc0982c53f1367af5636b12b7643cd03757fc" + revision = "a93e51b5a57ef416dac8bb02d11407b6f55d8929" + source = "https://github.com/carolynvs/semver.git" [[projects]] name = "github.com/Masterminds/vcs" @@ -58,6 +59,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "48b2f69d59b2f321b14ee11547f4ac94468ac91bb99aad48337d42b75b791975" + inputs-digest = "7c692c08851064cf6167056c23082edcf393d3af6bc0768c3111e0dde7444960" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 5cd77552db..fcd285c732 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,6 +1,7 @@ [[constraint]] - branch = "2.x" + branch = "parse-constraints-with-dash-in-pre" name = "github.com/Masterminds/semver" + source = "https://github.com/carolynvs/semver.git" [[constraint]] name = "github.com/Masterminds/vcs" diff --git a/vendor/github.com/Masterminds/semver/constraints.go b/vendor/github.com/Masterminds/semver/constraints.go index 628a44a161..164c011673 100644 --- a/vendor/github.com/Masterminds/semver/constraints.go +++ b/vendor/github.com/Masterminds/semver/constraints.go @@ -117,7 +117,7 @@ func NewConstraint(in string) (Constraint, error) { return newConstraint(in, false, constraintCache) } -// NewConstraintIC (ImpliedConstraint) is the same as NewConstraint, except that +// NewConstraintIC ("Implied Caret") is the same as NewConstraint, except that // it treats an absent operator as being equivalent to ^ instead of =. func NewConstraintIC(in string) (Constraint, error) { return newConstraint(in, true, constraintCacheIC) diff --git a/vendor/github.com/Masterminds/semver/constraints_test.go b/vendor/github.com/Masterminds/semver/constraints_test.go index a45714d746..cb77c89d61 100644 --- a/vendor/github.com/Masterminds/semver/constraints_test.go +++ b/vendor/github.com/Masterminds/semver/constraints_test.go @@ -53,6 +53,12 @@ func TestParseConstraint(t *testing.T) { includeMin: true, includeMax: false, }, false}, + {"^1.1.0-12-abc123", rangeConstraint{ + min: Version{major: 1, minor: 1, patch: 0, pre: "12-abc123"}, + max: newV(2, 0, 0), + includeMin: true, + includeMax: false, + }, false}, } for _, tc := range tests { @@ -70,7 +76,7 @@ func TestParseConstraint(t *testing.T) { } if !constraintEq(tc.c, c) { - t.Errorf("Incorrect version found on %s", tc.in) + t.Errorf("%q produced constraint %q, but expected %q", tc.in, c, tc.c) } } } @@ -331,6 +337,12 @@ func TestNewConstraintIC(t *testing.T) { max: newV(2, 0, 0), includeMin: true, }, false}, + {"v1.1.0-12-abc123", rangeConstraint{ + min: Version{major: 1, minor: 1, patch: 0, pre: "12-abc123"}, + max: newV(2, 0, 0), + includeMin: true, + includeMax: false, + }, false}, } for _, tc := range tests { @@ -548,6 +560,7 @@ func TestRewriteRange(t *testing.T) { {"2-3", ">= 2, <= 3"}, {"2-3, 2-3", ">= 2, <= 3,>= 2, <= 3"}, {"2-3, 4.0.0-5.1", ">= 2, <= 3,>= 4.0.0, <= 5.1"}, + {"v2-3, 2-3", "v2-3,>= 2, <= 3"}, } for _, tc := range tests { diff --git a/vendor/github.com/Masterminds/semver/parse.go b/vendor/github.com/Masterminds/semver/parse.go index d6afa6c907..d4ec22f2d2 100644 --- a/vendor/github.com/Masterminds/semver/parse.go +++ b/vendor/github.com/Masterminds/semver/parse.go @@ -13,6 +13,9 @@ func rewriteRange(i string) string { } o := i for _, v := range m { + if strings.HasPrefix(v[0], "v") && versionRegex.MatchString(v[0]) { + continue + } t := fmt.Sprintf(">= %s, <= %s", v[1], v[11]) o = strings.Replace(o, v[0], t, 1) } From 0cbbebd01cff16261f673e98d07158108f0168de Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Mon, 7 Aug 2017 09:54:44 -0500 Subject: [PATCH 2/2] Fix testdata Fix the godep testdata now that dep correctly converts a version with multiple dashes into a caret, instead of a bad range. --- cmd/dep/godep_importer_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/dep/godep_importer_test.go b/cmd/dep/godep_importer_test.go index c03fc9a13f..5504623176 100644 --- a/cmd/dep/godep_importer_test.go +++ b/cmd/dep/godep_importer_test.go @@ -192,8 +192,8 @@ func TestGodepConfig_ConvertProject_WithSemverSuffix(t *testing.T) { } v := d.Constraint.String() - if v != ">=1.12.0, <=12.0.0-g2fd980e" { - t.Fatalf("Expected manifest constraint to be >=1.12.0, <=12.0.0-g2fd980e, got %s", v) + if v != "^1.12.0-12-g2fd980e" { + t.Fatalf("Expected manifest constraint to be ^1.12.0-12-g2fd980e, got %s", v) } p := lock.P[0]