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

Version API Method Names #750

Merged
merged 2 commits into from
Jun 14, 2017
Merged
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 cmd/dep/glide_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestGlideConfig_Convert_Project(t *testing.T) {
}

wantRev := "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
gotRev := lpv.Underlying().String()
gotRev := lpv.Revision().String()
if gotRev != wantRev {
t.Fatalf("Expected locked revision to be %s, got %s", wantRev, gotRev)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/godep_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (g *godepImporter) buildLockedProject(pkg godepPackage) gps.LockedProject {

if pkg.Comment != "" {
ver := gps.NewVersion(pkg.Comment)
version = ver.Is(gps.Revision(pkg.Rev))
version = ver.Pair(gps.Revision(pkg.Rev))
} else {
version = gps.Revision(pkg.Rev)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/godep_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestGodepConfig_ConvertProject(t *testing.T) {
t.Fatalf("Expected locked version to be PairedVersion but got %T", lv)
}

rev := lpv.Underlying()
rev := lpv.Revision()
if rev != "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" {
t.Fatalf("Expected locked revision to be 'ff2948a2ac8f538c4ecd55962e919d1e13e74baf', got %s", rev)
}
Expand Down Expand Up @@ -208,7 +208,7 @@ func TestGodepConfig_ConvertProject_EmptyComment(t *testing.T) {
t.Fatalf("Expected locked version to be PairedVersion but got %T", lv)
}

rev := lpv.Underlying()
rev := lpv.Revision()
if rev != "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" {
t.Fatalf("Expected locked revision to be 'ff2948a2ac8f538c4ecd55962e919d1e13e74baf', got %s", rev)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/dep/gopath_scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,19 @@ func TestGetProjectPropertiesFromVersion(t *testing.T) {
want: wantSemver,
},
{
version: gps.NewBranch("foo-branch").Is("some-revision"),
version: gps.NewBranch("foo-branch").Pair("some-revision"),
want: gps.NewBranch("foo-branch"),
},
{
version: gps.NewVersion("foo-version").Is("some-revision"),
version: gps.NewVersion("foo-version").Pair("some-revision"),
want: gps.NewVersion("foo-version"),
},
{
version: gps.Revision("some-revision"),
want: nil,
},
{
version: gps.NewVersion("v1.0.0").Is("some-revision"),
version: gps.NewVersion("v1.0.0").Pair("some-revision"),
want: wantSemver,
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/root_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func lookupVersionForRevision(rev gps.Revision, pi gps.ProjectIdentifier, sm gps

gps.SortPairedForUpgrade(versions) // Sort versions in asc order
for _, v := range versions {
if v.Underlying() == rev {
if v.Revision() == rev {
return v, nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
bs.Revision = tv
case gps.PairedVersion:
bs.Version = tv.Unpair()
bs.Revision = tv.Underlying()
bs.Revision = tv.Revision()
}

// Check if the manifest has an override for this project. If so,
Expand Down Expand Up @@ -364,7 +364,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
// upgrade, the first version we encounter that
// matches our constraint will be what we want.
if c.Constraint.Matches(v) {
bs.Latest = v.Underlying()
bs.Latest = v.Revision()
break
}
}
Expand Down
4 changes: 2 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (c *Ctx) VersionInWorkspace(root gps.ProjectRoot) (gps.Version, error) {
if contains(tags, ver) {
// Assume semver if it starts with a v.
if strings.HasPrefix(ver, "v") {
return gps.NewVersion(ver).Is(gps.Revision(rev)), nil
return gps.NewVersion(ver).Pair(gps.Revision(rev)), nil
}

return nil, errors.Errorf("version for root %s does not start with a v: %q", pr, ver)
Expand All @@ -303,7 +303,7 @@ func (c *Ctx) VersionInWorkspace(root gps.ProjectRoot) (gps.Version, error) {
}
// Try to match the current version to a branch.
if contains(branches, ver) {
return gps.NewBranch(ver).Is(gps.Revision(rev)), nil
return gps.NewBranch(ver).Pair(gps.Revision(rev)), nil
}

return gps.Revision(rev), nil
Expand Down
4 changes: 2 additions & 2 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ func TestVersionInWorkspace(t *testing.T) {
checkout bool
}{
"github.com/pkg/errors": {
rev: gps.NewVersion("v0.8.0").Is("645ef00459ed84a119197bfb8d8205042c6df63d"), // semver
rev: gps.NewVersion("v0.8.0").Pair("645ef00459ed84a119197bfb8d8205042c6df63d"), // semver
checkout: true,
},
"github.com/Sirupsen/logrus": {
rev: gps.Revision("42b84f9ec624953ecbf81a94feccb3f5935c5edf"), // random sha
checkout: true,
},
"github.com/rsc/go-get-default-branch": {
rev: gps.NewBranch("another-branch").Is("8e6902fdd0361e8fa30226b350e62973e3625ed5"),
rev: gps.NewBranch("another-branch").Pair("8e6902fdd0361e8fa30226b350e62973e3625ed5"),
},
}

Expand Down
50 changes: 25 additions & 25 deletions internal/gps/constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// gu - helper func for stringifying what we assume is a VersionPair (otherwise
// will panic), but is given as a Constraint
func gu(v Constraint) string {
return fmt.Sprintf("%q at rev %q", v, v.(PairedVersion).Underlying())
return fmt.Sprintf("%q at rev %q", v, v.(PairedVersion).Revision())
}

func TestBranchConstraintOps(t *testing.T) {
Expand Down Expand Up @@ -47,7 +47,7 @@ func TestBranchConstraintOps(t *testing.T) {

// Add rev to one
snuffster := Revision("snuffleupagus")
v3 := v1.Is(snuffster).(versionPair)
v3 := v1.Pair(snuffster).(versionPair)
if v2.Matches(v3) {
t.Errorf("%s should not match %s", v2, gu(v3))
}
Expand All @@ -70,7 +70,7 @@ func TestBranchConstraintOps(t *testing.T) {
}

// Add different rev to the other
v4 := v2.Is(Revision("cookie monster")).(versionPair)
v4 := v2.Pair(Revision("cookie monster")).(versionPair)
if v4.Matches(v3) {
t.Errorf("%s should not match %s", gu(v4), gu(v3))
}
Expand All @@ -96,7 +96,7 @@ func TestBranchConstraintOps(t *testing.T) {
// TODO(sdboyer) this might not actually be a good idea, when you consider the
// semantics of floating versions...matching on an underlying rev might be
// nice in the short term, but it's probably shit most of the time
v5 := v2.Is(Revision("snuffleupagus")).(versionPair)
v5 := v2.Pair(Revision("snuffleupagus")).(versionPair)
if !v5.Matches(v3) {
t.Errorf("%s should match %s", gu(v5), gu(v3))
}
Expand All @@ -122,9 +122,9 @@ func TestBranchConstraintOps(t *testing.T) {
cookie := Revision("cookie monster")
o1 := NewVersion("master").(plainVersion)
o2 := NewVersion("1.0.0").(semVersion)
o3 := o1.Is(cookie).(versionPair)
o4 := o2.Is(cookie).(versionPair)
v6 := v1.Is(cookie).(versionPair)
o3 := o1.Pair(cookie).(versionPair)
o4 := o2.Pair(cookie).(versionPair)
v6 := v1.Pair(cookie).(versionPair)

if v1.Matches(o1) {
t.Errorf("%s (branch) should not match %s (version) across types", v1, o1)
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestVersionConstraintOps(t *testing.T) {

// Add rev to one
snuffster := Revision("snuffleupagus")
v3 := v1.Is(snuffster).(versionPair)
v3 := v1.Pair(snuffster).(versionPair)
if v2.Matches(v3) {
t.Errorf("%s should not match %s", v2, gu(v3))
}
Expand All @@ -254,7 +254,7 @@ func TestVersionConstraintOps(t *testing.T) {
}

// Add different rev to the other
v4 := v2.Is(Revision("cookie monster")).(versionPair)
v4 := v2.Pair(Revision("cookie monster")).(versionPair)
if v4.Matches(v3) {
t.Errorf("%s should not match %s", gu(v4), gu(v3))
}
Expand All @@ -277,7 +277,7 @@ func TestVersionConstraintOps(t *testing.T) {
}

// Now add same rev to different versions, and things should line up
v5 := v2.Is(Revision("snuffleupagus")).(versionPair)
v5 := v2.Pair(Revision("snuffleupagus")).(versionPair)
if !v5.Matches(v3) {
t.Errorf("%s should match %s", gu(v5), gu(v3))
}
Expand All @@ -303,9 +303,9 @@ func TestVersionConstraintOps(t *testing.T) {
cookie := Revision("cookie monster")
o1 := NewBranch("master").(branchVersion)
o2 := NewVersion("1.0.0").(semVersion)
o3 := o1.Is(cookie).(versionPair)
o4 := o2.Is(cookie).(versionPair)
v6 := v1.Is(cookie).(versionPair)
o3 := o1.Pair(cookie).(versionPair)
o4 := o2.Pair(cookie).(versionPair)
v6 := v1.Pair(cookie).(versionPair)

if v1.Matches(o1) {
t.Errorf("%s (version) should not match %s (branch) across types", v1, o1)
Expand Down Expand Up @@ -412,7 +412,7 @@ func TestSemverVersionConstraintOps(t *testing.T) {

// Add rev to one
snuffster := Revision("snuffleupagus")
v3 := v1.Is(snuffster).(versionPair)
v3 := v1.Pair(snuffster).(versionPair)
if v2.Matches(v3) {
t.Errorf("%s should not match %s", v2, gu(v3))
}
Expand All @@ -435,7 +435,7 @@ func TestSemverVersionConstraintOps(t *testing.T) {
}

// Add different rev to the other
v4 := v2.Is(Revision("cookie monster")).(versionPair)
v4 := v2.Pair(Revision("cookie monster")).(versionPair)
if v4.Matches(v3) {
t.Errorf("%s should not match %s", gu(v4), gu(v3))
}
Expand All @@ -458,7 +458,7 @@ func TestSemverVersionConstraintOps(t *testing.T) {
}

// Now add same rev to different versions, and things should line up
v5 := v2.Is(Revision("snuffleupagus")).(versionPair)
v5 := v2.Pair(Revision("snuffleupagus")).(versionPair)
if !v5.Matches(v3) {
t.Errorf("%s should match %s", gu(v5), gu(v3))
}
Expand All @@ -484,9 +484,9 @@ func TestSemverVersionConstraintOps(t *testing.T) {
cookie := Revision("cookie monster")
o1 := NewBranch("master").(branchVersion)
o2 := NewVersion("ab123").(plainVersion)
o3 := o1.Is(cookie).(versionPair)
o4 := o2.Is(cookie).(versionPair)
v6 := v1.Is(cookie).(versionPair)
o3 := o1.Pair(cookie).(versionPair)
o4 := o2.Pair(cookie).(versionPair)
v6 := v1.Pair(cookie).(versionPair)

if v1.Matches(o1) {
t.Errorf("%s (semver) should not match %s (branch) across types", v1, o1)
Expand Down Expand Up @@ -586,9 +586,9 @@ func TestSemverConstraintOps(t *testing.T) {
v3 := NewVersion("1.0.0").(semVersion)

fozzie := Revision("fozzie bear")
v4 := v1.Is(fozzie).(versionPair)
v5 := v2.Is(fozzie).(versionPair)
v6 := v3.Is(fozzie).(versionPair)
v4 := v1.Pair(fozzie).(versionPair)
v5 := v2.Pair(fozzie).(versionPair)
v6 := v3.Pair(fozzie).(versionPair)

// TODO(sdboyer) we can't use the same range as below b/c semver.rangeConstraint is
// still an incomparable type
Expand Down Expand Up @@ -702,9 +702,9 @@ func TestVersionUnion(t *testing.T) {
rev := Revision("flooboofoobooo")
v1 := NewBranch("master")
v2 := NewBranch("test")
v3 := NewVersion("1.0.0").Is(rev)
v3 := NewVersion("1.0.0").Pair(rev)
v4 := NewVersion("1.0.1")
v5 := NewVersion("v2.0.5").Is(Revision("notamatch"))
v5 := NewVersion("v2.0.5").Pair(Revision("notamatch"))

uv1 := versionTypeUnion{v1, v4, rev}
uv2 := versionTypeUnion{v2, v3}
Expand Down Expand Up @@ -877,7 +877,7 @@ func TestTypedConstraintString(t *testing.T) {
// Also tests typedVersionString(), as this nests down into that
rev := Revision("flooboofoobooo")
v1 := NewBranch("master")
v2 := NewBranch("test").Is(rev)
v2 := NewBranch("test").Pair(rev)
v3 := NewVersion("1.0.1")
v4 := NewVersion("v2.0.5")
v5 := NewVersion("2.0.5.2")
Expand Down
2 changes: 1 addition & 1 deletion internal/gps/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (lp LockedProject) Version() Version {
return lp.r
}

return lp.v.Is(lp.r)
return lp.v.Pair(lp.r)
}

// Eq checks if two LockedProject instances are equal.
Expand Down
6 changes: 3 additions & 3 deletions internal/gps/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestLockedProjectsEq(t *testing.T) {
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0"), []string{"gps", "flugle"}),
NewLockedProject(mkPI("foo"), NewVersion("nada"), []string{"foo"}),
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0"), []string{"flugle", "gps"}),
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0").Is("278a227dfc3d595a33a77ff3f841fd8ca1bc8cd0"), []string{"gps"}),
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0").Pair("278a227dfc3d595a33a77ff3f841fd8ca1bc8cd0"), []string{"gps"}),
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.11.0"), []string{"gps"}),
NewLockedProject(mkPI("github.com/sdboyer/gps"), Revision("278a227dfc3d595a33a77ff3f841fd8ca1bc8cd0"), []string{"gps"}),
}
Expand Down Expand Up @@ -81,9 +81,9 @@ func TestLockedProjectsEq(t *testing.T) {
}

func TestLocksAreEq(t *testing.T) {
gpl := NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0").Is("278a227dfc3d595a33a77ff3f841fd8ca1bc8cd0"), []string{"gps"})
gpl := NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0").Pair("278a227dfc3d595a33a77ff3f841fd8ca1bc8cd0"), []string{"gps"})
svpl := NewLockedProject(mkPI("github.com/Masterminds/semver"), NewVersion("v2.0.0"), []string{"semver"})
bbbt := NewLockedProject(mkPI("github.com/beeblebrox/browntown"), NewBranch("master").Is("63fc17eb7966a6f4cc0b742bf42731c52c4ac740"), []string{"browntown", "smoochies"})
bbbt := NewLockedProject(mkPI("github.com/beeblebrox/browntown"), NewBranch("master").Pair("63fc17eb7966a6f4cc0b742bf42731c52c4ac740"), []string{"browntown", "smoochies"})

l1 := solution{
hd: []byte("foo"),
Expand Down
34 changes: 17 additions & 17 deletions internal/gps/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ func TestSourceInit(t *testing.T) {
t.Errorf("Expected seven version results from the test repo, got %v", len(pvl))
} else {
expected := []PairedVersion{
NewVersion("v2.0.0").Is(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
NewVersion("v1.1.0").Is(Revision("b2cb48dda625f6640b34d9ffb664533359ac8b91")),
NewVersion("v1.0.0").Is(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
newDefaultBranch("master").Is(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
NewBranch("v1").Is(Revision("e3777f683305eafca223aefe56b4e8ecf103f467")),
NewBranch("v1.1").Is(Revision("f1fbc520489a98306eb28c235204e39fa8a89c84")),
NewBranch("v3").Is(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
NewVersion("v2.0.0").Pair(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
NewVersion("v1.1.0").Pair(Revision("b2cb48dda625f6640b34d9ffb664533359ac8b91")),
NewVersion("v1.0.0").Pair(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
newDefaultBranch("master").Pair(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
NewBranch("v1").Pair(Revision("e3777f683305eafca223aefe56b4e8ecf103f467")),
NewBranch("v1.1").Pair(Revision("f1fbc520489a98306eb28c235204e39fa8a89c84")),
NewBranch("v3").Pair(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
}

// SourceManager itself doesn't guarantee ordering; sort them here so we
Expand Down Expand Up @@ -186,13 +186,13 @@ func TestSourceInit(t *testing.T) {
t.Errorf("Expected seven version results from the test repo, got %v", len(vl))
} else {
expected := []Version{
NewVersion("v2.0.0").Is(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
NewVersion("v1.1.0").Is(Revision("b2cb48dda625f6640b34d9ffb664533359ac8b91")),
NewVersion("v1.0.0").Is(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
newDefaultBranch("master").Is(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
NewBranch("v1").Is(Revision("e3777f683305eafca223aefe56b4e8ecf103f467")),
NewBranch("v1.1").Is(Revision("f1fbc520489a98306eb28c235204e39fa8a89c84")),
NewBranch("v3").Is(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
NewVersion("v2.0.0").Pair(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
NewVersion("v1.1.0").Pair(Revision("b2cb48dda625f6640b34d9ffb664533359ac8b91")),
NewVersion("v1.0.0").Pair(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
newDefaultBranch("master").Pair(Revision("bf85021c0405edbc4f3648b0603818d641674f72")),
NewBranch("v1").Pair(Revision("e3777f683305eafca223aefe56b4e8ecf103f467")),
NewBranch("v1.1").Pair(Revision("f1fbc520489a98306eb28c235204e39fa8a89c84")),
NewBranch("v3").Pair(Revision("4a54adf81c75375d26d376459c00d5ff9b703e5e")),
}

for k, e := range expected {
Expand Down Expand Up @@ -273,9 +273,9 @@ func TestDefaultBranchAssignment(t *testing.T) {
brev := Revision("fda020843ac81352004b9dca3fcccdd517600149")
mrev := Revision("9f9c3a591773d9b28128309ac7a9a72abcab267d")
expected := []PairedVersion{
NewBranch("branchone").Is(brev),
NewBranch("otherbranch").Is(brev),
NewBranch("master").Is(mrev),
NewBranch("branchone").Pair(brev),
NewBranch("otherbranch").Pair(brev),
NewBranch("master").Pair(mrev),
}

SortPairedForUpgrade(v)
Expand Down
Loading