Skip to content

Commit 48a53d6

Browse files
author
Bryan C. Mills
committed
cmd/go/internal/modfetch: use the resolved version to search for tags in (*codeRepo).convert
Previously, we used the passed-in statVers as the basis for tag search, but it is not always valid. Instead, use info.Name, which (by precondition) must be valid. Updates #32161 Updates #27171 Change-Id: Iaecb5043bdf2fefd26fbe3f8e3714b07d22f580f Reviewed-on: https://go-review.googlesource.com/c/go/+/179857 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent f61fa11 commit 48a53d6

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/cmd/go/internal/modconv/convert_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,19 @@ func TestConvertLegacyConfig(t *testing.T) {
106106
github.com/AdRoll/goamz v0.0.0-20150130162828-d3664b76d905
107107
github.com/MSOpenTech/azure-sdk-for-go v0.0.0-20150323223030-d90753bcad2e
108108
github.com/Sirupsen/logrus v0.7.3
109-
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd
109+
github.com/bugsnag/bugsnag-go v1.0.3-0.20141110184014-b1d153021fcd
110110
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b
111111
github.com/bugsnag/panicwrap v0.0.0-20141110184334-e5f9854865b9
112-
github.com/codegangsta/cli v0.0.0-20150131031259-6086d7927ec3
113-
github.com/docker/docker v0.0.0-20150204013315-165ea5c158cf
112+
github.com/codegangsta/cli v1.4.2-0.20150131031259-6086d7927ec3
113+
github.com/docker/docker v1.4.2-0.20150204013315-165ea5c158cf
114114
github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1
115115
github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7
116116
github.com/gorilla/context v0.0.0-20140604161150-14f550f51af5
117117
github.com/gorilla/handlers v0.0.0-20140825150757-0e84b7d810c1
118118
github.com/gorilla/mux v0.0.0-20140926153814-e444e69cbd2e
119119
github.com/jlhawn/go-crypto v0.0.0-20150401213827-cd738dde20f0
120120
github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43
121-
github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50
121+
github.com/yvasiyarov/gorelic v0.0.7-0.20141212073537-a9bba5b9ab50
122122
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f
123123
golang.org/x/net v0.0.0-20150202051010-1dfe7915deaf
124124
gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789
@@ -138,7 +138,7 @@ func TestConvertLegacyConfig(t *testing.T) {
138138
github.com/googleapis/gax-go v2.0.0+incompatible
139139
golang.org/x/net v0.0.0-20180216171745-136a25c244d3
140140
golang.org/x/oauth2 v0.0.0-20180207181906-543e37812f10
141-
golang.org/x/text v0.0.0-20180208041248-4e4a3210bb54
141+
golang.org/x/text v0.3.1-0.20180208041248-4e4a3210bb54
142142
google.golang.org/api v0.0.0-20180217000815-c7a403bb5fe1
143143
google.golang.org/appengine v1.0.0
144144
google.golang.org/genproto v0.0.0-20180206005123-2b5a72b8730b

src/cmd/go/internal/modfetch/coderepo.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ func (r *codeRepo) Latest() (*RevInfo, error) {
208208
return r.convert(info, "")
209209
}
210210

211+
// convert converts a version as reported by the code host to a version as
212+
// interpreted by the module system.
213+
//
214+
// If statVers is a valid module version, it is used for the Version field.
215+
// Otherwise, the Version is derived from the passed-in info and recent tags.
211216
func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, error) {
212217
info2 := &RevInfo{
213218
Name: info.Name,
@@ -268,7 +273,7 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e
268273
}
269274
// Otherwise make a pseudo-version.
270275
if info2.Version == "" {
271-
tag, _ := r.code.RecentTag(statVers, p)
276+
tag, _ := r.code.RecentTag(info.Name, p)
272277
v = tagToVersion(tag)
273278
// TODO: Check that v is OK for r.pseudoMajor or else is OK for incompatible.
274279
info2.Version = PseudoVersion(r.pseudoMajor, v, info.Time, info.Short)

src/cmd/go/testdata/script/mod_init_glide.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
env GO111MODULE=on
2-
31
[!net] skip
42
[!exec:git] skip
53

6-
# test glide replacement
4+
env GO111MODULE=on
5+
env GOPROXY=direct
6+
7+
# Regression test for golang.org/issue/32161:
8+
# 'go mod init' did not locate tags when resolving a commit to a pseudo-version.
79
go mod init x
810
cmpenv go.mod go.mod.out
911

0 commit comments

Comments
 (0)