From 676fa2caed96f6ee34b628d1644640e64ea8886d Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Tue, 17 Sep 2019 15:16:28 -0400 Subject: content,internal/frontend: add README and license source filepaths For modules hosted on github.com, bitbucket.org and golang.org, the URL path is displayed. For other modules the zip filepath is displayed. Fixes b/140933339 Fixes b/137207297 Change-Id: I536051c638d6fe05696d91aae0a40f065d563918 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/553297 CI-Result: Cloud Build Reviewed-by: Jonathan Amsterdam --- internal/stdlib/stdlib.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'internal/stdlib/stdlib.go') diff --git a/internal/stdlib/stdlib.go b/internal/stdlib/stdlib.go index 242ebba7..d386d0f2 100644 --- a/internal/stdlib/stdlib.go +++ b/internal/stdlib/stdlib.go @@ -40,7 +40,9 @@ const ModulePath = "std" // TagForVersion returns the Go standard library repository tag corresponding // to semver. The Go tags differ from standard semantic versions in a few ways, // such as beginning with "go" instead of "v". -func TagForVersion(version string) (string, error) { +func TagForVersion(version string) (_ string, err error) { + defer derrors.Wrap(&err, "TagForVersion(%q)", version) + if !semver.IsValid(version) { return "", derrors.FromHTTPStatus(http.StatusBadRequest, "requested version is not a valid semantic version: %q ", version) } @@ -86,7 +88,7 @@ func finalDigitsIndex(s string) int { return i + 1 } -const goRepoURL = "https://go.googlesource.com/go" +const GoRepoURL = "https://go.googlesource.com/go" // UseTestData determines whether to really clone the Go repo, or use // stripped-down versions of the repo from the testdata directory. @@ -102,7 +104,7 @@ func getGoRepo(version string) (_ *git.Repository, err error) { return nil, err } return git.Clone(memory.NewStorage(), nil, &git.CloneOptions{ - URL: goRepoURL, + URL: GoRepoURL, ReferenceName: plumbing.NewTagReferenceName(tag), SingleBranch: true, Depth: 1, @@ -148,7 +150,7 @@ func Versions() (_ []string, err error) { refNames = testRefs } else { re := git.NewRemote(memory.NewStorage(), &config.RemoteConfig{ - URLs: []string{goRepoURL}, + URLs: []string{GoRepoURL}, }) refs, err := re.List(&git.ListOptions{}) if err != nil { -- cgit v1.3-5-g9baa