golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.52k stars 17.6k forks source link

x/pkgsite: surface VCS clone path from the go-import meta tag #46243

Open mvdan opened 3 years ago

mvdan commented 3 years ago

Take golang.org/x/mod, for example:

$ curl https://golang.org/x/mod
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="go-import" content="golang.org/x/mod git https://go.googlesource.com/mod">
<meta name="go-source" content="golang.org/x/mod https://github.com/golang/mod/ https://github.com/golang/mod/tree/master{/dir} https://github.com/golang/mod/blob/master{/dir}/{file}#L{line}">
<meta http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/mod">
</head>
<body>
<a href="https://pkg.go.dev/golang.org/x/mod">Redirecting to documentation...</a>
</body>
</html>

If I go to https://pkg.go.dev/golang.org/x/mod, the only link I see is https://github.com/golang/mod, which is fine for browsing the source - but not for git clone, as github is just a mirror. I should be using https://go.googlesource.com/mod for that, but pkgsite doesn't make that evident.

I get that perhaps this is an internal detail that most people shouldn't need to be aware of, but it's still relevant for peoplel wishing to contribute to a module. Especially for the x repos hosted by Gerrit - I seem to recall that you have to clone from the right URL for git-codereview to work properly.

bcmills commented 3 years ago

(Compare #18387 for cmd/go.)

bcmills commented 3 years ago

It may be that pkgsite itself doesn't have this information at the moment. (We may need #44742 for that.)

dmitshur commented 3 years ago

I've closed #47520 as a duplicate of this issue.

shellscape commented 3 years ago

Please resurface that meta tag, as it was infinitely useful for anyone performing insight on their imports. Vanity paths have no other means of gleaning information on the repo other than to scrape HTML. Combined with the lack of an API to provide package metadata, the new site and forced redirect cripple consumer insight into packages.

I'd also suggest placing any other useful information into meta tags in lieu of an API. That's at least somewhat functional and quasi-contractual.