aboutsummaryrefslogtreecommitdiff
path: root/internal/fetch/unit.go
AgeCommit message (Collapse)Author
2026-03-26internal: consolidate build context and unit resolution logicEthan Lee
- Centralize logic for resolving units and selecting the best matching build context. - New helpers MatchingBuildContext, SortedBuildContexts provide a consistent, efficient approach to build context selection. - DocumentationForBuildContext now finds the best match based on precdence rules rather than just returning the first match. - A new getUnitContext helper resolves unit metadata and the best build context in a single query. - GetSymbols and GetUnit are now both optimized to use pre-resolved IDs, simplifying their queries and removing redundant joins. - Replaced redundant matchingDoc functions in fetchdatasource and fakedatasource. Change-Id: I9207d3bfe03404483c816090a0b99666f14a36e3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/759162 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ethan Lee <ethanalee@google.com>
2024-02-06internal/fetch: split FetchModule in twoMichael Matloob
First we get a LazyModule that essentially just contains the UnitMetas for each of the modules and then we process each Unit as needed so that FetchDataSource doesn't need to process all the Units when it just needs one. To construct at FetchResult, FetchModule will now get a LazyModule and then compute all the Units. A compromise to get this to work is that FetchDataSource will no longer populate Synopsis, IsRedistributable and Licenses on Subdirectories to avoid computing all those fields for all units when returning a single unit. MainVersion and MasterVersion are removed from FetchResult because they were only set on the internal/worker.FetchTask struct that embeds a FetchResult. Change-Id: Ia0db850ae570d421712ec484ee8b7815a779128e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/557818 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2024-01-23internal: move UnitMeta.IsRedistributable to UnitMichael Matloob
Change-Id: Ia0a18df32d752f20b0400b47860638c7d0910eb7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/556435 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
2024-01-22internal: move UnitMeta.Licenses to UnitMichael Matloob
Change-Id: If2b3c1acd4830948e2d134517608f89771a7abcb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/555735 kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-07internal/fetch: put ModuleInfo into each unitJonathan Amsterdam
Install the full ModuleInfo from the parent module into each unit. Previously this wasn't necessary in fetch because Unit.ModuleInfo was populated when reading from the DB. But it's necessary now that we can serve directly from a fetched module. For golang/go#47982 Change-Id: I0b0462148f7623ccbbbe7d4ca3bf2409e2107023 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/347931 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-08-24internal/fetch: populate Unit.BuildContextsJonathan Amsterdam
Populate the lists of build contexts when fetching a module. Currently we only do this when reading from the DB. We want DataSources that rely only on fetch to have the right value. For golang/go#47780 Change-Id: Ie85fba8ccb318bb4ed5c1f2153b0ba4216358022 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/344670 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-25internal: embed ModuleInfo into UnitMetaJonathan Amsterdam
UnitMeta had most of the fields of ModuleInfo, but did not embed it. Now that we have added four more fields to ModuleInfo for deprecation and retraction, it makes sense to embed it rather than duplicate those fields. For golang/go#43265 For golang/go#41321 Change-Id: I20e2b922b49c7873a5535745d644631123de37cd Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296209 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-08internal/fetch: collapse identical build contextsJonathan Amsterdam
If all the build contexts for a package produce the same documentation, then return a single Documentation with build context all/all. This will save a lot of space in the documentation table, since most packages will fit into this case. For golang/go#37232 Change-Id: I15237242e0c3ca3c7b8f8c8944b227afebd23785 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/289680 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-02many: allow for multiple documentations for a UnitJonathan Amsterdam
Change internal.Unit.Documentation from a single internal.Documentation to a slice, so that a Unit can have doc for multiple build contexts. However, don't use this ability yet: fetch takes only the first build context it finds, postgres inserts only the first, frontend renders only the first, etc. For golang/go#37232 Change-Id: I17fd1ff2378e0862c029c8077057c207001f6136 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/288217 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> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2020-12-29internal/fetch: support multiple build contextsJonathan Amsterdam
Extend the goPackage type to handle multiple documentation build contexts (GOOS/GOARCH combinations). When goPackages are coverted to Units, ignore all but the first. For golang/go#37232 Change-Id: I706e6e407c2b3c31963032f1db5aa9a297e7ad8a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/279458 Trust: Jonathan Amsterdam <jba@google.com> Trust: Julie Qiu <julie@golang.org> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2020-11-24many: remove Documentation.HTMLJonathan Amsterdam
HTML is always generated from source, so the Documentation.HTML field is no longer necessary. Change-Id: I13cddbfbd983c8a2ff0cb9389e854887caadcc13 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/272509 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-09-29internal/postgres: read and write source filesJonathan Amsterdam
Write the encoded source files to the documentation.source column when a module is inserted, and read them back from getDocumentation. Change-Id: I9fc27c570c701522c9e00c6bf9270dbe51f8602d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258237 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-21internal/fetch: rename directory.go to unit.goJulie Qiu
Change-Id: Iae06d3363e3565ef384eb87c0d25297f10e96792 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/256308 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>