aboutsummaryrefslogtreecommitdiff
path: root/internal/source/source.go
AgeCommit message (Collapse)Author
2026-03-26all: run go fix -slicescontainsHana Kim
Change-Id: I14479d9e612dfa7eed9188206746af5b51c10201 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753428 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2024-10-01internal/source: support git.glasklar.is URLsGrégoire Détrez
Fixes #69638 Change-Id: I9b595bcc98d2d92895ad3d626981aa551ce75d07 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/609535 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Bypass: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-08-30internal/trace: add a wrapper for tracingMichael Matloob
This package adds a StartSpan function that does nothing unless an implementation for the StartSpan function is injected in. That allows us to have the frontend and worker mains inject the implementation while internal/fetch and internal/source can use the StartSpan function without depending on opencensus's tracing library. For golang/go#61399 Change-Id: I2c650bdbb56c8fcc47ffabab8353cef74e0d1c4e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/523739 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Michael Matloob <matloob@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29internal/source: inject *http.Client into source.NewClientMichael Matloob
This removes the dependency from package source onto ochttp. The users of source.NewClient that want an ochttp.Transport can set the transport on the *http.Client. For golang/go#61399 Change-Id: Ifb7126c482f664ee5a359f594d9324f0fd90f8b2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/523510 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com>
2023-07-17internal/fetch: add two stdlib gettersMichael Matloob
This breaks out the behavior of getting the stdlib into its own getter, stdlibZipModuleGetter. Most (but not all) of the special cases in the fetch code for the stdlib are in the stdlibZipModuleGetter, which is installed on the frontend. For the local pkgsite command, we add a new builder for the goPackagesModuleGetter that loads the packages from the stdlib given a GOROOT. The stdlibZipModuleGetter is also installed for pkgsite in as a fallback if the goPackagesModuleGetter doesn't successfully fetch the stdlib module (I'm not sure if that's possible). Fixes #60114 Change-Id: Ida6a5367343643cc337c6d05e0d40095f79ca9e5 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/507883 Reviewed-by: Jamal Carvalho <jamal@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com>
2023-07-12internal: fix build on WindowsMichael Matloob
Disable some of the vuln tests on windows because one of the path conversion functions fails with an error saying it doesn't work on Windows. Also fix the behavior on windows for /file paths. It looks like they are intended to be /file/+filepath.ToSlash(filesystemPath) when on Windows. Make sure we always generate those paths, and check for those paths. Change-Id: I23738b463b1415f2a75598dab4eaa511791f8e7e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/508503 Run-TryBot: Michael Matloob <matloob@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2023-02-09internal: fix some commentscui fliter
Change-Id: I837c46bba9cd5c012670b432274c6e3318a3275b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/465997 Reviewed-by: Suzy Mueller <suzmue@golang.org> Run-TryBot: Suzy Mueller <suzmue@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Auto-Submit: Suzy Mueller <suzmue@golang.org>
2022-05-27internal/source: support codebergDaniel Jakots
Change-Id: Iac98a43ac9fd5182eebc154413992db4912e8b28 GitHub-Last-Rev: 3fadfc82655153f93f849e907e3f66e4bb135e0a GitHub-Pull-Request: golang/pkgsite#44 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/401814 Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-04-11all: gofmtRuss Cox
Gofmt to update doc comments to the new formatting. For golang/go#51082. Change-Id: Ia9e71e7ecac75822ff43d6c7e60f512442a5fa50 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/399617 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-01-05internal/source: fix gitlab patternsJonathan Amsterdam
The source patterns for GitLab incorrectly assumed them to be identical to GitHub's. GitLab repos can have multiple path components, and the general path syntax allows for that by placing a "-" path component between the repo and reference. Fixes golang/go#49827 Change-Id: I766c303fb443b80af882931a5bfa151aa3363089 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/375281 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-09-24internal/source: support github.* URLsJonathan Amsterdam
These URLs are used by some GitHub Enterprise Server customers. For golang/go#48542 Change-Id: Iace7e9db14fcb776669c2ae581a7508c188c1aca Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/351276 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-09-07cmd/pkgsite,internal: serve sourceJonathan Amsterdam
- Set up a /files endpoint on the server that can serve files from fs.FS implementations. - Add source.FilesInfo, which returns a source.Info that links to /files paths. Use it to implement the SourceInfo method of the local ModuleGetters. - Add a SourceFS method to the local MethodGetters so they can tell the server how to serve their files. - Improve the tests in cmd/pkgsite to verify the source links. Fixes golang/go#47982 Change-Id: Iff42bad15c4abaf408a364e58b7c0f0dad60b40d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/347932 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-06-10internal/source: change golang.org/* reposJulie Qiu
Rather than using github.com/golang/* for the golang.org/* repos, use cs.googlesource.com/go when available. Change-Id: I88acf4c1316b160b0852ef954a515276e92ad975 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/326190 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com>
2021-05-12internal: change stdlib source repoJulie Qiu
The stdlib source repo is changed to https://cs.opensource.google/go/go. Fixes golang/go#44832 Change-Id: Ie8060ab1cabccbcf9ff20c0eec42c243c1feaf9c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/318873 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-03-22internal/source: handle blitiri.com.ar import pathsJonathan Amsterdam
The source for these import paths is served by the git-arr web viewer, which doesn't yet handle tags. Until it does, serve the source from master. For golang/go#44607 Change-Id: I94047a887ea6f1038ae812864ad343876b74ff8e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/303609 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-02-11internal/source: support example.com domain for testingJonathan Amsterdam
For golang/go#44214 Change-Id: I70a3cbfa62cc051949437ecba94b8667d12dff3e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290896 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-02internal/source: trim .git suffix from repo URLsJonathan Amsterdam
Remove the ".git" from the repo URL of source templates when we know it will result in invalid URLs. The ".git" is understood by the Go command, but not by some code hosting sites. To be safe, only remove it on code hosting sites we've tested. For now, that's GitHub and GitLab. Remove the suffix in three places: 1. When we construct a SourceInfo from the repo URL and meta tags. This will fix newly processed modules. 2. When we unmarshal a SourceInfo from the DB. This will fix it during rendering for already-processed modules. It will save us from having to reprocess or backfill. 3. In the function we use in tests. Fixes golang/go#44032 Change-Id: Ic6d48d0422dc12ce8dbc4586f8d6c586f463531e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/288612 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-01-21internal/source: match old templates to find new onesJonathan Amsterdam
Previously, when we encountered a repo whose URL doesn't match an existing pattern, we did not generate any URL templates for it, meaning we could not render source links in the documentation. This CL uses the templates in the go-source meta tag to guess the version-aware templates that are likely to work for the repo. For golang/go#40477 Change-Id: I2d1978da5a6de1af19284233dbab9ac1ae2cb582 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/285312 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2020-12-22internal/source: enable testing without HTTP requestsJonathan Amsterdam
Add NewClientForTesting, which returns a Client that does not make any HTTP requests. The practical effect is to eliminate a lot of errors from test logs in the internal/fetch package. Change-Id: Ie47ceb1a8984d4408ea361baefa1610aeed1b02a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/279793 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2020-12-15internal/source,stdlib: change stdlib source repo to go.googlesource.comJonathan Amsterdam
Link to source files in the canonical Go repo, go.googlesource.com/go. Continue to serve raw content (for images) from the GitHub mirror, since we can't from googlesource.com. Fixes golang/go#43180 Change-Id: Iac513d6481bcdb73ae73eed40d33518ffd3a0158 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/278293 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-12-04internal/source: update gitea commentJonathan Amsterdam
For golang/go#39559 Change-Id: Id9c2ae0bcac9299565695d79a66f4bf591e60364 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/274956 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2020-09-30internal/source: fix documentationJulie Qiu
source.ModuleInfo is incorrectly documented as source.LegacyModuleInfo, which is now fixed. A comment in RawURL is also fixed. For golang/go#39629 Change-Id: I30b650f2895970e36446659a02a6f3e8e54ef578 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258301 Reviewed-by: Jamal Carvalho <jamal@golang.org> Trust: Julie Qiu <julie@golang.org>
2020-08-28internal/source: add support for dmitri.shuralyov.com/... packagesDmitri Shuralyov
Add support for a set of packages that defer to another website to display their source code. To be able to produce expected URLs, we need to add two more URL template variables: • {importPath} - Package import path ("example.com/myrepo/mypkg"). • {base} - Base name of file containing the identifier, including file extension ("file.go"). Also add a new optional Repo URL template for overriding the home page of the repository, which is something that was possible with the original go-source meta tag. Document the existing URL template variables, so that it's easier to understand how to use them. For golang/go#40477. Change-Id: I70b857155f69c5c3ed41e78daccb90153a927290 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/246239 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-29internal/source: tweak commentsJonathan Amsterdam
Change-Id: Id5871a052193a32a90be7f6fd1d199807049bc28 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245381 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-29internal/source: support some more URLsJonathan Amsterdam
Change-Id: I23b20b711ac892a86e0a8bdceccacef6f4665191 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245380 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-29internal/source: support gitea.* URLsJonathan Amsterdam
Treat any repo URL beginning with "gitea." as if it uses the Gitea system. Also, sanity-check templates and fix some bugs. Change-Id: Ib6c3ca028d57e05504faef4bfdf6aa4439525fb7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245379 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-28internal/source: support more code-hosting sitesJonathan Amsterdam
Suport git.fd.io, fit.pirl.io, and gitea. For golang/go#39019 Change-Id: I4e4fbf617598435803d209fc6150b7c8e56a0f72 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245259 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-28internal/source: remove incorrect commentsJonathan Amsterdam
Change-Id: Ia8c1a67608fe334de11da8366920fe36211cbe85 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245258 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-28internal/source: simplify pattern specificationJonathan Amsterdam
Allow regexps to be specified as strings. Change-Id: Icad485e0ec798a99691c002754bc104526e48a84 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245257 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-28internal/source: add sourcehut templatesJonathan Amsterdam
Add source templates for the sourcehut git hosting site (git.sr.ht). Fixes golang/go#38986. Change-Id: I581389affe3c777828189d8aa35e3910ffe1d130 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245039 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-27internal/source: remove extraneous commentsJonathan Amsterdam
It's not important whether certain patterns are part of the go command or not. Change-Id: I8e921b0f2256efa419b3df41a9d1925cb0fa8cd7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245037 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-21internal/source: remove HTML escapingJonathan Amsterdam
Now that the entire server uses safehtml, it is no longer necessary to do anything special with the user-provided values in this package. Every use of the Info.XXXURL methods is part of rendering a safe template, so all the escaping will happen then. Change-Id: I5e64b08d4c7b8e7fd56cf1a0bed49691f2a8ee82 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/242917 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-17internal/source: use better github raw templateJonathan Amsterdam
Replace the previous github template for raw data (raw.githubusercontent...) with a new one that is more uniform (the same as the blob template, with "raw" instead of "blob"). The main advantage is that we can drop the "repoPath" parameter to the template, which was necessary only to support the unusual GitHub URLs. Now that GitHub and GitLab templates are identical, we can drop the GitLab ones. We preserve "gitlab" in the map from kinds to templates so we can continue to unmarshal DB modules.source_info columns that use "gitlab". Change-Id: Id3d45929f0eb2c040109449d4208279cca44f079 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/243217 Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-30internal/fetch/dochtml: update package documentation and issue numbersDmitri Shuralyov
There has been progress made since the package comments were written. Update them to reflect the current state. For golang/go#39621. Change-Id: I3f950428a96bc0561b45b0d49117d2eda58d3cf7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240187 Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-23internal/{source,frontend}: escape HTMLJonathan Amsterdam
Escape any strings that may come from outside the program and will be rendered as HTML. Also, fix some typos. Also, put args to a cmp.Diff call in the right order. Change-Id: I1fc6013e200326af8719b14c28a607fc7936e20a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/239478 Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-17internal: clean up issue linksJulie Qiu
This is the first CL to clean up various TODOs that are outdated, and replace internal issue links with GitHub issue links. Updates golang/go#39621 Change-Id: If270e8b2e8198c007cb4aa71ad8486182f4f3380 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/238319 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-09internal: rename ModuleInfo to LegacyModuleInfoJulie Qiu
ModuleInfo is renamed to LegacyModuleInfo, as a step towards deprecating LegacyReadmeFilePath and LegacyReadmeContents. In a follow up CL, we will add ModuleInfo as an embedded struct to LegacyModuleInfo. Change-Id: Ie452420448eec1d13edaf62e548df0b9e2cbbe4b Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/766479 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-08internal: prefix legacy structs with LegacyJulie Qiu
The following structs have been renamed with a Legacy prefix: * internal.Directory * internal.Package * internal.VersionedPackage * sample.Package The following fields on internal.ModuleInfo have also been changed: * ReadmeFilePath * ReadmeFileContents This is done to help us distinguish between legacy and method structs/methods while migrating code to the new data model. Change-Id: Ibedf71d4db6323ef5aa05d73a0240537ea6073d3 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/765160 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-29internal: add traces fetch processJulie Qiu
Additional traces are added to the fetch process so that we can get more detailed information on what is taking up time in a fetch process. Change-Id: I8f74a0d2117a18002d64453d222cb08a1fb81ff2 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/729482 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-23all: rename module to golang.org/x/pkgsiteJulie Qiu
golang.org/x/discovery is renamed to golang.org/x/pkgsite. When the repository is open sourced, it will be hosted at go.googlesource.com/pkgsite. Change-Id: Ifc3b45b771a385b99179e785447f2a87afcacf87 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/724273 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-07internal/worker: fix missing sourceClient initializationJulie Qiu
sourceClient wasn't being initialized by worker.NewServer, which led to a nil pointer error that is now fixed. Change-Id: I5d16e69e60c9a1ba489a0b5ec0e3a1a6a1f19366 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/711165 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06internal/source: add ClientJulie Qiu
source.Client is added, which replaces the used of http.DefaultClient when fetching source code. This also allows us to set a custom timeout for tests vs when running the worker. Change-Id: I5b7b0fd32fa7a2cf836b951af1ad471751fade00 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/709198 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27internal/{log,middleware}: add trace ID to context, use in loggingJonathan Amsterdam
- The requestlog middleware gets the trace ID from the request and adds it to the request's context. - The internal/log package retrieves the traceID and adds it to log messages. It also creates two logs instead of one, a "parent" log used in requestlog, and a "child" log used for all other logging. Together, these two changes will cause the Stackdriver log viewer to group all log messages for a request with the request start and end log messages. - These changes require that all log functions take a context, so I plumbed one through everywhere. In a handful of cases it didn't seem worth doing the plumbing. I used context.TODO() for those so we can easily find and re-evalaute them. Change-Id: I663588463520187d0549a8f802ba9cb44a893592 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/622940 Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27internal/source: read body even on errorJonathan Amsterdam
Some sites (gonum.org in particular) return an error status (like 404) to a ?go=get=1 URL, but also serve a body with meta tags. Ignore the 404 for the http request. Fixes b/144596157. Change-Id: Ib59177b6847890975768de8fe4b623e188828f1f Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/622164 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/license,internal/postgres: store license coverage in DBJonathan Amsterdam
Store the output of licensecheck.Cover in the licenses table. This will make our lives easier if we ever want to revisit our coverage parameters. In the process, generalize scanning of jsonb columns into Go values. Change-Id: Iadc89c89c2590e0894fefcdcd461283d90b2e701 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/601900 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/source: handle raw links to the std module speciallyJonathan Amsterdam
The module directory we use to create links to the standard module's source is "src". That is only partly true, however: the .go files are there, but the README is at the repo root. This matters when constructing raw links from the README. We add a special check for this case in Info.RawURL. Note that this is a bit fragile and hacky: if we ever wanted a raw link to a source file, for example, the URL would be wrong. But the only alternative I can see now is to make everything more complicated just for this one case, which isn't worth it. Fixes b/143208537. Change-Id: Ide47b3739eaaf9f6b7e9b4631811ca3695353bb3 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/584337 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/frontend: translate relative non-image links in readmesJonathan Amsterdam
If a Readme has a relative link that is not an image, convert it to an absolute link to the file using source info. Fixes b/140250096. Change-Id: I9ca629963ca87d7605c0217e49671b33c7dd0f86 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/576296 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/frontend: use source.Info to translate relative linksJonathan Amsterdam
- Change translateRelativeLink to use the source.Info.RawURL method. - Remove internal.VersionInfo.RepositoryURL; it is redundant. - Remove unnecessary tests from overview_test.go; they no longer make sense or are effectively tested in internal/source. Change-Id: Ibcf7f120ca1d257178b84ee69d22ca256de0b766 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/575158 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/source,postgres: save source info to the DBJonathan Amsterdam
- Add a SourceInfo field to VersionInfo. - Add functions to convert a source.Info to and from JSON. - Modify postgres statements to read and write from the DB. Keep the VersionInfo.RepositoryURL field around for now to avoid messing with the frontend. Updates b/132219298, b/138752200. Change-Id: I6ebb3af3afa14fda92c2804ab2d0294742a3bf41 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/575156 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/version: add package for version typesJonathan Amsterdam
Move some version-related code like IsPseudoVersion from internal to a new package. This is needed to break an import cycle: - internal.VersionInfo needs a *source.Info field - internal/source needs to call internal.IsPseudoVersion Change-Id: I125bd019bc2ec9cec9d1ec0945bbaafdfecc5cfc Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/573775 Reviewed-by: Julie Qiu <julieqiu@google.com>