diff options
| author | Julie Qiu <julie@golang.org> | 2020-10-25 21:46:17 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-10-26 13:03:05 +0000 |
| commit | c4e44bdaacbd99881378c8b055ee9031f182484f (patch) | |
| tree | 9d8a22ab07ba389ba3cc7fcc687981c1ef3ee9ce /internal/testing/sample | |
| parent | 013c7f06492c1e6f4fadd608144ee638b4601d34 (diff) | |
| download | go-x-pkgsite-c4e44bdaacbd99881378c8b055ee9031f182484f.tar.xz | |
internal/testing/sample: deprecate legacyUnitForPackage
legacyUnitForPackage is deprecated in favor of UnitForPackage.
legacyUnitForModuleRoot is also renamed to UnitForModuleRoot.
For golang/go#39629
Change-Id: I73f781e570552656262f9982bb2a018937598306
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265002
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/testing/sample')
| -rw-r--r-- | internal/testing/sample/legacy.go | 22 | ||||
| -rw-r--r-- | internal/testing/sample/sample.go | 13 |
2 files changed, 8 insertions, 27 deletions
diff --git a/internal/testing/sample/legacy.go b/internal/testing/sample/legacy.go index d7f4b19d..181f754c 100644 --- a/internal/testing/sample/legacy.go +++ b/internal/testing/sample/legacy.go @@ -50,13 +50,13 @@ func LegacyModule(modulePath, version string, suffixes ...string) *internal.Modu ModuleInfo: *mi, Licenses: Licenses, } - m.Units = []*internal.Unit{legacyUnitForModuleRoot(mi)} + m.Units = []*internal.Unit{UnitForModuleRoot(mi)} for _, s := range suffixes { lp := LegacyPackage(modulePath, s) if s != "" { LegacyAddPackage(m, lp) } else { - u := legacyUnitForPackage(lp, modulePath, version) + u := UnitForPackage(lp.Path, modulePath, version, lp.Name, lp.IsRedistributable) m.Units[0].Documentation = u.Documentation m.Units[0].Name = u.Name } @@ -69,7 +69,7 @@ func LegacyAddPackage(m *internal.Module, p *internal.LegacyPackage) *internal.M panic(fmt.Sprintf("package path %q not a prefix of module path %q", p.Path, m.ModulePath)) } - AddUnit(m, legacyUnitForPackage(p, m.ModulePath, m.Version)) + AddUnit(m, UnitForPackage(p.Path, m.ModulePath, m.Version, p.Name, p.IsRedistributable)) minLen := len(m.ModulePath) if m.ModulePath == stdlib.ModulePath { minLen = 1 @@ -89,7 +89,7 @@ func LegacyAddPackage(m *internal.Module, p *internal.LegacyPackage) *internal.M return m } -func legacyUnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit { +func UnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit { u := &internal.Unit{ UnitMeta: *UnitMeta(m.ModulePath, m.ModulePath, m.Version, "", m.IsRedistributable), LicenseContents: Licenses, @@ -100,17 +100,3 @@ func legacyUnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit { } return u } - -func legacyUnitForPackage(pkg *internal.LegacyPackage, modulePath, version string) *internal.Unit { - return &internal.Unit{ - UnitMeta: *UnitMeta(pkg.Path, modulePath, version, pkg.Name, pkg.IsRedistributable), - Imports: pkg.Imports, - LicenseContents: Licenses, - Documentation: &internal.Documentation{ - Synopsis: pkg.Synopsis, - HTML: pkg.DocumentationHTML, - GOOS: pkg.GOOS, - GOARCH: pkg.GOARCH, - }, - } -} diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go index 5cd47938..45b3e88a 100644 --- a/internal/testing/sample/sample.go +++ b/internal/testing/sample/sample.go @@ -100,22 +100,17 @@ func NowTruncated() time.Time { // is the concatenation of modulePath and suffix. // // The package name is last component of the package path. -func UnitForPackage(modulePath, suffix string) *internal.Unit { - p := constructFullPath(modulePath, suffix) +func UnitForPackage(path, modulePath, version, name string, isRedistributable bool) *internal.Unit { return &internal.Unit{ - UnitMeta: internal.UnitMeta{ - Name: path.Base(p), - Path: p, - IsRedistributable: true, - Licenses: LicenseMetadata, - }, + UnitMeta: *UnitMeta(path, modulePath, version, name, isRedistributable), Documentation: &internal.Documentation{ Synopsis: Synopsis, HTML: DocumentationHTML, GOOS: GOOS, GOARCH: GOARCH, }, - Imports: Imports, + LicenseContents: Licenses, + Imports: Imports, } } |
