Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Update Masterminds/semver to latest 2.x #573

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/gps/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewSemverConstraint(body string) (Constraint, error) {
}
// If we got a simple semver.Version, simplify by returning our
// corresponding type
if sv, ok := c.(*semver.Version); ok {
if sv, ok := c.(semver.Version); ok {
return semVersion{sv: sv}, nil
}
return semverConstraint{c: c}, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/gps/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (a naiveAnalyzer) Info() (name string, version int) {
return "naive-analyzer", 1
}

func sv(s string) *semver.Version {
func sv(s string) semver.Version {
sv, err := semver.NewVersion(s)
if err != nil {
panic(fmt.Sprintf("Error creating semver from %q: %s", s, err))
Expand Down
6 changes: 3 additions & 3 deletions internal/gps/vcs_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, erro
vlist := make([]PairedVersion, len(ovlist))
k := 0
var dbranch int // index of branch to be marked default
var bsv *semver.Version
var bsv semver.Version
for _, v := range ovlist {
// all git versions will always be paired
pv := v.(versionPair)
Expand All @@ -318,7 +318,7 @@ func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, erro
// which one to mark as default until we've seen them all
tv.isDefault = false
// Figure out if this is the current leader for default branch
if bsv == nil || bsv.LessThan(sv) {
if bsv == (semver.Version{}) || bsv.LessThan(sv) {
bsv = sv
dbranch = k
}
Expand All @@ -331,7 +331,7 @@ func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, erro
}

vlist = vlist[:k]
if bsv != nil {
if bsv != (semver.Version{}) {
dbv := vlist[dbranch].(versionPair)
vlist[dbranch] = branchVersion{
name: dbv.v.(branchVersion).name,
Expand Down
2 changes: 1 addition & 1 deletion internal/gps/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (v plainVersion) Is(r Revision) PairedVersion {
}

type semVersion struct {
sv *semver.Version
sv semver.Version
}

func (v semVersion) String() string {
Expand Down
2 changes: 1 addition & 1 deletion manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestReadManifest(t *testing.T) {
t.Fatalf("Should have read Manifest correctly, but got err %q", err)
}

c, _ := gps.NewSemverConstraint(">=0.12.0, <1.0.0")
c, _ := gps.NewSemverConstraint("^0.12.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't absorbed the full context here yet, but just noting that these two aren't equivalent. By the definitions used in Masterminds/semver, ^0.12.0 is equivalent to >=0.12.0, <0.13.0.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the repo's readme, I believe those are equal. The change may not be necessary if the testdata is not updated, I'll test this out locally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not 😄 Masterminds/semver#53

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note that updating the README there is one of the last TODOs before releasing v2.0.0)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense now :p

want := Manifest{
Dependencies: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/dep/internal/gps"): {
Expand Down
2 changes: 1 addition & 1 deletion testdata/manifest/golden.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ignored = ["github.com/foo/bar"]

[[dependencies]]
name = "github.com/golang/dep/internal/gps"
version = ">=0.12.0, <1.0.0"
version = "^0.12.0"

[[overrides]]
branch = "master"
Expand Down
5 changes: 2 additions & 3 deletions vendor/github.com/Masterminds/semver/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/Masterminds/semver/collection.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 35 additions & 15 deletions vendor/github.com/Masterminds/semver/constraints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading