From 84574e5b8d2668d5f07f7bb7ee8ae19b7dfd22c3 Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Sun, 31 Jan 2021 22:06:02 -0500 Subject: content,internal: update versions page The versions page is updated to: - Display incompatible versions in a separate section - Remove minor versions of other modules A version.IsIncompatible function is added to the internal/version package for determining if a version is an incompatible version. Mock: https://photos.app.goo.gl/wWEFsMrmtaxggTAk7 Change-Id: I9a1c533066c3ea8b3f9f9b65f9bd171290655b5e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/288762 Trust: Julie Qiu Run-TryBot: Julie Qiu TryBot-Result: kokoro Reviewed-by: Jonathan Amsterdam --- internal/postgres/insert_module.go | 8 +------- internal/postgres/versionstate.go | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'internal/postgres') diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go index 8d68bece..1d979a84 100644 --- a/internal/postgres/insert_module.go +++ b/internal/postgres/insert_module.go @@ -205,7 +205,7 @@ func insertModule(ctx context.Context, db *database.DB, m *internal.Module) (_ i m.IsRedistributable, m.HasGoMod, m.DeprecatedComment, - isIncompatible(m.Version), + version.IsIncompatible(m.Version), ).Scan(&moduleID) if err != nil { return 0, err @@ -581,12 +581,6 @@ func lock(ctx context.Context, tx *database.DB, modulePath string) (err error) { return nil } -// isIncompatible reports whether the build metadata of the version is -// "+incompatible", https://semver.org clause 10. -func isIncompatible(version string) bool { - return strings.HasSuffix(version, "+incompatible") -} - // isLatestVersion reports whether version is the latest version of the module. func isLatestVersion(ctx context.Context, ddb *database.DB, modulePath, resolvedVersion string) (_ bool, err error) { defer derrors.WrapStack(&err, "isLatestVersion(ctx, tx, %q)", modulePath) diff --git a/internal/postgres/versionstate.go b/internal/postgres/versionstate.go index 1674005d..e91ca58b 100644 --- a/internal/postgres/versionstate.go +++ b/internal/postgres/versionstate.go @@ -27,7 +27,7 @@ func (db *DB) InsertIndexVersions(ctx context.Context, versions []*internal.Inde var vals []interface{} for _, v := range versions { - vals = append(vals, v.Path, v.Version, version.ForSorting(v.Version), v.Timestamp, 0, "", "", isIncompatible(v.Version)) + vals = append(vals, v.Path, v.Version, version.ForSorting(v.Version), v.Timestamp, 0, "", "", version.IsIncompatible(v.Version)) } cols := []string{"module_path", "version", "sort_version", "index_timestamp", "status", "error", "go_mod_path", "incompatible"} conflictAction := ` @@ -116,7 +116,7 @@ func upsertModuleVersionState(ctx context.Context, db *database.DB, modulePath, CURRENT_TIMESTAMP + INTERVAL '1 hour' END;`, modulePath, vers, version.ForSorting(vers), - appVersion, timestamp, status, goModPath, sqlErrorMsg, numPackages, isIncompatible(vers)) + appVersion, timestamp, status, goModPath, sqlErrorMsg, numPackages, version.IsIncompatible(vers)) if err != nil { return err } -- cgit v1.3-5-g45d5