Skip to content

Commit 3dedcc9

Browse files
committed
cmd/go/internal/modfetch: fix conversion of legacy v2 versions
If a legacy requirement file (for example Gopkg.lock) lists a package x.com/y/z at version v2.0.0, we assume that is not a module-aware package, so it should be addressed as a pseudo-version v0.0.0-date-hash. But the converter was allowing the v2.0.0 through, which then failed the next time vgo was invoked. This CL rejects during conversion (meaning they turn into pseudo-versions) any versions that don't match the expected major version for the given module path. Fixes golang/go#24056. Fixes golang/go#24585. Change-Id: Ib2c9ea31d2581fd55cae32e8c89c3587bd658a60 Reviewed-on: https://go-review.googlesource.com/107660 Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 84430ca commit 3dedcc9

File tree

3 files changed

+177
-1
lines changed

3 files changed

+177
-1
lines changed

vendor/cmd/go/internal/modfetch/coderepo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (r *codeRepo) Latest() (*RevInfo, error) {
144144

145145
func (r *codeRepo) convert(info *codehost.RevInfo) (*RevInfo, error) {
146146
versionOK := func(v string) bool {
147-
return semver.IsValid(v) && v == semver.Canonical(v) && !isPseudoVersion(v)
147+
return semver.IsValid(v) && v == semver.Canonical(v) && !isPseudoVersion(v) && module.MatchPathMajor(v, r.pathMajor)
148148
}
149149
v := info.Version
150150
if r.codeDir == "" {

vendor/cmd/go/internal/modfetch/convert_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@ func TestConvertLegacyConfig(t *testing.T) {
7878
gopkg.in/yaml.v2 v0.0.0-20150116202057-bef53efd0c76
7979
)`,
8080
},
81+
82+
{
83+
// golang.org/issue/24585 - confusion about v2.0.0 tag in legacy non-v2 module
84+
"github.com/fishy/gcsbucket", "v0.0.0-20150410205453-618d60fe84e0",
85+
`module github.com/fishy/gcsbucket
86+
87+
require (
88+
cloud.google.com/go v0.18.0
89+
github.com/fishy/fsdb v0.0.0-20180217030800-5527ded01371
90+
github.com/golang/protobuf v1.0.0
91+
github.com/googleapis/gax-go v0.0.0-20170915024731-317e0006254c
92+
golang.org/x/net v0.0.0-20180216171745-136a25c244d3
93+
golang.org/x/oauth2 v0.0.0-20180207181906-543e37812f10
94+
golang.org/x/text v0.0.0-20180208041248-4e4a3210bb54
95+
google.golang.org/api v0.0.0-20180217000815-c7a403bb5fe1
96+
google.golang.org/appengine v1.0.0
97+
google.golang.org/genproto v0.0.0-20180206005123-2b5a72b8730b
98+
google.golang.org/grpc v1.10.0
99+
)`,
100+
},
81101
}
82102

83103
for _, tt := range tests {

vendor/cmd/go/internal/modfetch/testdata/webtest.txt

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11885,3 +11885,159 @@ X-Xss-Protection: 1; mode=block
1188511885

1188611886
[{"sha":"c4d4236f92427c64bfbcf1cc3f8142ab18f30b22","commit":{"author":{"name":"Russ Cox","email":"[email protected]","date":"2018-02-14T15:44:20Z"},"committer":{"name":"Russ Cox","email":"[email protected]","date":"2018-02-14T15:44:20Z"},"message":"buggy: add buggy test","tree":{"sha":"704e33398b7ad1e36f346ac3c9a6858f444ee91d","url":"https://api.github.com/repos/rsc/quote/git/trees/704e33398b7ad1e36f346ac3c9a6858f444ee91d"},"url":"https://api.github.com/repos/rsc/quote/git/commits/c4d4236f92427c64bfbcf1cc3f8142ab18f30b22","comment_count":0,"verification":{"verified":false,"reason":"unsigned","signature":null,"payload":null}},"url":"https://api.github.com/repos/rsc/quote/commits/c4d4236f92427c64bfbcf1cc3f8142ab18f30b22","html_url":"https://github.com/rsc/quote/commit/c4d4236f92427c64bfbcf1cc3f8142ab18f30b22","comments_url":"https://api.github.com/repos/rsc/quote/commits/c4d4236f92427c64bfbcf1cc3f8142ab18f30b22/comments","author":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"committer":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"parents":[{"sha":"23179ee8a569bb05d896ae05c6503ec69a19f99f","url":"https://api.github.com/repos/rsc/quote/commits/23179ee8a569bb05d896ae05c6503ec69a19f99f","html_url":"https://github.com/rsc/quote/commit/23179ee8a569bb05d896ae05c6503ec69a19f99f"}]},{"sha":"23179ee8a569bb05d896ae05c6503ec69a19f99f","commit":{"author":{"name":"Russ Cox","email":"[email protected]","date":"2018-02-14T00:58:40Z"},"committer":{"name":"Russ Cox","email":"[email protected]","date":"2018-02-14T00:58:40Z"},"message":"quote: fix test for new rsc.io/sampler","tree":{"sha":"98dea458b6a7805a98272ad43b4f92b76cdea71a","url":"https://api.github.com/repos/rsc/quote/git/trees/98dea458b6a7805a98272ad43b4f92b76cdea71a"},"url":"https://api.github.com/repos/rsc/quote/git/commits/23179ee8a569bb05d896ae05c6503ec69a19f99f","comment_count":0,"verification":{"verified":false,"reason":"unsigned","signature":null,"payload":null}},"url":"https://api.github.com/repos/rsc/quote/commits/23179ee8a569bb05d896ae05c6503ec69a19f99f","html_url":"https://github.com/rsc/quote/commit/23179ee8a569bb05d896ae05c6503ec69a19f99f","comments_url":"https://api.github.com/repos/rsc/quote/commits/23179ee8a569bb05d896ae05c6503ec69a19f99f/comments","author":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"committer":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"parents":[{"sha":"3ba1e30dc83bd52c990132b9dfb1688a9d22de13","url":"https://api.github.com/repos/rsc/quote/commits/3ba1e30dc83bd52c990132b9dfb1688a9d22de13","html_url":"https://github.com/rsc/quote/commit/3ba1e30dc83bd52c990132b9dfb1688a9d22de13"}]}]
1188711887

11888+
GET https://cloud.google.com/go?go-get=1
11889+
200 OK
11890+
Alt-Svc: hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35"
11891+
Cache-Control: must_revalidate, public, max-age=3600
11892+
Content-Language: en
11893+
Content-Type: text/html; charset=utf-8
11894+
Date: Wed, 18 Apr 2018 05:07:38 GMT
11895+
Etag: 528a8b11588abe6bae8b251357168d2d
11896+
Expires: Wed, 18 Apr 2018 06:07:38 GMT
11897+
Last-Modified: Tue, 05 Dec 2017 00:31:55 GMT
11898+
Server: Google Frontend
11899+
Strict-Transport-Security: max-age=31536000; includeSubdomains
11900+
Vary: Accept-Language
11901+
Vary: Accept-Encoding
11902+
X-Cloud-Trace-Context: dbe9a6946ea98afa1ac8819261423928
11903+
X-Content-Type-Options: nosniff
11904+
X-Frame-Options: SAMEORIGIN
11905+
X-Xss-Protection: 1; mode=block
11906+
11907+
<!DOCTYPE html>
11908+
<html>
11909+
<head>
11910+
<meta name="go-import" content="cloud.google.com/go git https://code.googlesource.com/gocloud">
11911+
<meta name="go-source" content="cloud.google.com/go https://github.com/GoogleCloudPlatform/gcloud-golang https://github.com/GoogleCloudPlatform/gcloud-golang/tree/master{/dir} https://github.com/GoogleCloudPlatform/gcloud-golang/tree/master{/dir}/{file}#L{line}">
11912+
<meta http-equiv="refresh" content="0; url=/go/home">
11913+
</head>
11914+
<body>
11915+
Nothing to see here. Please <a href="/go/home">move along</a>.
11916+
</body>
11917+
</html>
11918+
11919+
11920+
GET https://golang.org/x/oauth2?go-get=1
11921+
200 OK
11922+
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
11923+
Cache-Control: private
11924+
Content-Type: text/html; charset=utf-8
11925+
Date: Wed, 18 Apr 2018 05:07:42 GMT
11926+
Server: Google Frontend
11927+
Vary: Accept-Encoding
11928+
X-Cloud-Trace-Context: ebec1e646ce2eb5445befb0685c56026
11929+
11930+
<!DOCTYPE html>
11931+
<html>
11932+
<head>
11933+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
11934+
<meta name="go-import" content="golang.org/x/oauth2 git https://go.googlesource.com/oauth2">
11935+
<meta name="go-source" content="golang.org/x/oauth2 https://github.com/golang/oauth2/ https://github.com/golang/oauth2/tree/master{/dir} https://github.com/golang/oauth2/blob/master{/dir}/{file}#L{line}">
11936+
<meta http-equiv="refresh" content="0; url=https://godoc.org/golang.org/x/oauth2">
11937+
</head>
11938+
<body>
11939+
Nothing to see here; <a href="https://godoc.org/golang.org/x/oauth2">move along</a>.
11940+
</body>
11941+
</html>
11942+
11943+
11944+
GET https://google.golang.org/api?go-get=1
11945+
200 OK
11946+
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
11947+
Cache-Control: private
11948+
Content-Type: text/html; charset=utf-8
11949+
Date: Wed, 18 Apr 2018 05:07:45 GMT
11950+
Server: Google Frontend
11951+
Vary: Accept-Encoding
11952+
X-Cloud-Trace-Context: 94f300e3d779c4a7279740a20695444e
11953+
11954+
<!DOCTYPE html>
11955+
<html>
11956+
<head>
11957+
<meta name="go-import" content="google.golang.org/api git https://code.googlesource.com/google-api-go-client">
11958+
11959+
<meta name="go-source" content="google.golang.org/api https://github.com/google/google-api-go-client https://github.com/google/google-api-go-client/tree/master{/dir} https://github.com/google/google-api-go-client/tree/master{/dir}/{file}#L{line}">
11960+
11961+
<meta http-equiv="refresh" content="0; url=https://godoc.org/google.golang.org/api">
11962+
</head>
11963+
<body>
11964+
Nothing to see here. Please <a href="https://godoc.org/google.golang.org/api">move along</a>.
11965+
</body>
11966+
</html>
11967+
11968+
11969+
GET https://google.golang.org/appengine?go-get=1
11970+
200 OK
11971+
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
11972+
Cache-Control: private
11973+
Content-Type: text/html; charset=utf-8
11974+
Date: Wed, 18 Apr 2018 05:07:48 GMT
11975+
Server: Google Frontend
11976+
Vary: Accept-Encoding
11977+
X-Cloud-Trace-Context: 87b445f8e8f4c945c7c45da3d658677b
11978+
11979+
<!DOCTYPE html>
11980+
<html>
11981+
<head>
11982+
<meta name="go-import" content="google.golang.org/appengine git https://github.com/golang/appengine">
11983+
11984+
<meta name="go-source" content="google.golang.org/appengine https://github.com/golang/appengine https://github.com/golang/appengine/tree/master{/dir} https://github.com/golang/appengine/tree/master{/dir}/{file}#L{line}">
11985+
11986+
<meta http-equiv="refresh" content="0; url=https://godoc.org/google.golang.org/appengine">
11987+
</head>
11988+
<body>
11989+
Nothing to see here. Please <a href="https://godoc.org/google.golang.org/appengine">move along</a>.
11990+
</body>
11991+
</html>
11992+
11993+
11994+
GET https://google.golang.org/genproto?go-get=1
11995+
200 OK
11996+
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
11997+
Cache-Control: private
11998+
Content-Type: text/html; charset=utf-8
11999+
Date: Wed, 18 Apr 2018 05:07:49 GMT
12000+
Server: Google Frontend
12001+
Vary: Accept-Encoding
12002+
X-Cloud-Trace-Context: 06acf25d8499e19eef19d7ea32a3032f
12003+
12004+
<!DOCTYPE html>
12005+
<html>
12006+
<head>
12007+
<meta name="go-import" content="google.golang.org/genproto git https://github.com/google/go-genproto">
12008+
12009+
<meta name="go-source" content="google.golang.org/genproto https://github.com/google/go-genproto https://github.com/google/go-genproto/tree/master{/dir} https://github.com/google/go-genproto/tree/master{/dir}/{file}#L{line}">
12010+
12011+
<meta http-equiv="refresh" content="0; url=https://godoc.org/google.golang.org/genproto">
12012+
</head>
12013+
<body>
12014+
Nothing to see here. Please <a href="https://godoc.org/google.golang.org/genproto">move along</a>.
12015+
</body>
12016+
</html>
12017+
12018+
12019+
GET https://google.golang.org/grpc?go-get=1
12020+
200 OK
12021+
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
12022+
Cache-Control: private
12023+
Content-Type: text/html; charset=utf-8
12024+
Date: Wed, 18 Apr 2018 05:07:50 GMT
12025+
Server: Google Frontend
12026+
Vary: Accept-Encoding
12027+
X-Cloud-Trace-Context: e56994b2c8c2295223f321ddde66db7f
12028+
12029+
<!DOCTYPE html>
12030+
<html>
12031+
<head>
12032+
<meta name="go-import" content="google.golang.org/grpc git https://github.com/grpc/grpc-go">
12033+
12034+
<meta name="go-source" content="google.golang.org/grpc https://github.com/grpc/grpc-go https://github.com/grpc/grpc-go/tree/master{/dir} https://github.com/grpc/grpc-go/tree/master{/dir}/{file}#L{line}">
12035+
12036+
<meta http-equiv="refresh" content="0; url=https://godoc.org/google.golang.org/grpc">
12037+
</head>
12038+
<body>
12039+
Nothing to see here. Please <a href="https://godoc.org/google.golang.org/grpc">move along</a>.
12040+
</body>
12041+
</html>
12042+
12043+

0 commit comments

Comments
 (0)