internal/frontend: add legacy prefix to fetch*VersionDetails

The "legacy" prefix is added to fetchPackageVersionDetails and
fetchModuleVersionDetails, since these will be replaced with a
fetchVersionDetails function that reads from the paths table.

For golang/go#39629

Change-Id: I059a26cb5998b831e9be725a055ac1ce9692fee4
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/242580
Reviewed-by: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
Julie Qiu 2020-07-15 00:13:56 -04:00
Родитель 6ffa811e8a
Коммит 784e1b734f
3 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@ -147,7 +147,7 @@ func legacyFetchDetailsForPackage(r *http.Request, tab string, ds internal.DataS
case "doc":
return legacyFetchDocumentationDetails(pkg), nil
case "versions":
return fetchPackageVersionsDetails(ctx, ds, pkg.Path, pkg.V1Path, pkg.ModulePath)
return legacyFetchPackageVersionsDetails(ctx, ds, pkg.Path, pkg.V1Path, pkg.ModulePath)
case "subdirectories":
return legacyFetchDirectoryDetails(ctx, ds, pkg.Path, &pkg.ModuleInfo, pkg.Licenses, false)
case "imports":
@ -179,7 +179,7 @@ func fetchDetailsForPackage(r *http.Request, tab string, ds internal.DataSource,
case "subdirectories":
return fetchDirectoryDetails(ctx, ds, vdir, false)
case "versions":
return fetchPackageVersionsDetails(ctx, ds, vdir.Path, vdir.V1Path, vdir.ModulePath)
return legacyFetchPackageVersionsDetails(ctx, ds, vdir.Path, vdir.V1Path, vdir.ModulePath)
case "imports":
return fetchImportsDetails(ctx, ds, vdir.Path, vdir.ModulePath, vdir.Version)
case "importedby":
@ -219,7 +219,7 @@ func fetchDetailsForModule(r *http.Request, tab string, ds internal.DataSource,
case "licenses":
return &LicensesDetails{Licenses: transformLicenses(mi.ModulePath, mi.Version, licenses)}, nil
case "versions":
return fetchModuleVersionsDetails(ctx, ds, mi)
return legacyFetchModuleVersionsDetails(ctx, ds, mi)
case "overview":
return constructOverviewDetails(ctx, mi, readme, mi.IsRedistributable, urlIsVersioned(r.URL))
}

Просмотреть файл

@ -60,9 +60,9 @@ type VersionSummary struct {
Version string
}
// fetchModuleVersionsDetails builds a version hierarchy for module versions
// legacyFetchModuleVersionsDetails builds a version hierarchy for module versions
// with the same series path as the given version.
func fetchModuleVersionsDetails(ctx context.Context, ds internal.DataSource, mi *internal.ModuleInfo) (*VersionsDetails, error) {
func legacyFetchModuleVersionsDetails(ctx context.Context, ds internal.DataSource, mi *internal.ModuleInfo) (*VersionsDetails, error) {
versions, err := ds.LegacyGetTaggedVersionsForModule(ctx, mi.ModulePath)
if err != nil {
return nil, err
@ -81,9 +81,9 @@ func fetchModuleVersionsDetails(ctx context.Context, ds internal.DataSource, mi
return buildVersionDetails(mi.ModulePath, versions, linkify), nil
}
// fetchPackageVersionsDetails builds a version hierarchy for all module
// legacyFetchPackageVersionsDetails builds a version hierarchy for all module
// versions containing a package path with v1 import path matching the given v1 path.
func fetchPackageVersionsDetails(ctx context.Context, ds internal.DataSource, pkgPath, v1Path, modulePath string) (*VersionsDetails, error) {
func legacyFetchPackageVersionsDetails(ctx context.Context, ds internal.DataSource, pkgPath, v1Path, modulePath string) (*VersionsDetails, error) {
versions, err := ds.LegacyGetTaggedVersionsForPackageSeries(ctx, pkgPath)
if err != nil {
return nil, err

Просмотреть файл

@ -131,12 +131,12 @@ func TestFetchModuleVersionDetails(t *testing.T) {
}
}
got, err := fetchModuleVersionsDetails(ctx, testDB, tc.info)
got, err := legacyFetchModuleVersionsDetails(ctx, testDB, tc.info)
if err != nil {
t.Fatalf("fetchModuleVersionsDetails(ctx, db, %v): %v", tc.info, err)
t.Fatalf("legacyFetchModuleVersionsDetails(ctx, db, %v): %v", tc.info, err)
}
if diff := cmp.Diff(tc.wantDetails, got); diff != "" {
t.Errorf("fetchModuleVersionsDetails(ctx, db, %v) mismatch (-want +got):\n%s", tc.info, diff)
t.Errorf("legacyFetchModuleVersionsDetails(ctx, db, %v) mismatch (-want +got):\n%s", tc.info, diff)
}
})
}
@ -259,12 +259,12 @@ func TestFetchPackageVersionsDetails(t *testing.T) {
}
}
got, err := fetchPackageVersionsDetails(ctx, testDB, tc.pkg.Path, tc.pkg.V1Path, tc.pkg.ModulePath)
got, err := legacyFetchPackageVersionsDetails(ctx, testDB, tc.pkg.Path, tc.pkg.V1Path, tc.pkg.ModulePath)
if err != nil {
t.Fatalf("fetchPackageVersionsDetails(ctx, db, %v): %v", tc.pkg, err)
t.Fatalf("legacyFetchPackageVersionsDetails(ctx, db, %v): %v", tc.pkg, err)
}
if diff := cmp.Diff(tc.wantDetails, got); diff != "" {
t.Errorf("fetchPackageVersionsDetails(ctx, db, %v) mismatch (-want +got):\n%s", tc.pkg, diff)
t.Errorf("legacyFetchPackageVersionsDetails(ctx, db, %v) mismatch (-want +got):\n%s", tc.pkg, diff)
}
})
}