@@ -13,6 +13,7 @@ import ( |
| 13 | 13 | |
| 14 | 14 | "github.com/tenseleyFlow/shithub/internal/auth/policy" |
| 15 | 15 | repogit "github.com/tenseleyFlow/shithub/internal/repos/git" |
| 16 | + "github.com/tenseleyFlow/shithub/internal/repos/sigverify" |
| 16 | 17 | reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc" |
| 17 | 18 | "github.com/tenseleyFlow/shithub/internal/web/middleware" |
| 18 | 19 | ) |
@@ -159,12 +160,13 @@ func (h *Handlers) tagsList(w http.ResponseWriter, r *http.Request) { |
| 159 | 160 | refs, _ := repogit.ListRefs(r.Context(), gitDir) |
| 160 | 161 | |
| 161 | 162 | type tagRow struct { |
| 162 | | - Name string |
| 163 | | - OID string |
| 164 | | - ShortOID string |
| 165 | | - Subject string |
| 166 | | - AuthorName string |
| 167 | | - AuthorWhen time.Time |
| 163 | + Name string |
| 164 | + OID string |
| 165 | + ShortOID string |
| 166 | + Subject string |
| 167 | + AuthorName string |
| 168 | + AuthorWhen time.Time |
| 169 | + Verification sigverify.View |
| 168 | 170 | } |
| 169 | 171 | rows := make([]tagRow, 0, len(refs.Tags)) |
| 170 | 172 | for _, t := range refs.Tags { |
@@ -183,6 +185,26 @@ func (h *Handlers) tagsList(w http.ResponseWriter, r *http.Request) { |
| 183 | 185 | return rows[i].AuthorWhen.After(rows[j].AuthorWhen) |
| 184 | 186 | }) |
| 185 | 187 | |
| 188 | + // Batch-load tag-object verifications for the page. Cache misses |
| 189 | + // fall through to UnsignedView; the badge partial renders nothing |
| 190 | + // for unsigned, so unannotated/unsigned tags simply have no badge. |
| 191 | + oids := make([]string, 0, len(rows)) |
| 192 | + for _, tr := range rows { |
| 193 | + if tr.OID != "" { |
| 194 | + oids = append(oids, tr.OID) |
| 195 | + } |
| 196 | + } |
| 197 | + if len(oids) > 0 { |
| 198 | + verifications, vErr := sigverify.LoadViewsForOIDs(r.Context(), h.d.Pool, row.ID, oids) |
| 199 | + if vErr != nil { |
| 200 | + h.d.Logger.WarnContext(r.Context(), "tagsList: load verifications", "error", vErr, "repo_id", row.ID) |
| 201 | + verifications = map[string]sigverify.View{} |
| 202 | + } |
| 203 | + for i := range rows { |
| 204 | + rows[i].Verification = sigverify.LookupView(verifications, rows[i].OID) |
| 205 | + } |
| 206 | + } |
| 207 | + |
| 186 | 208 | h.d.Render.RenderPage(w, r, "repo/tags", map[string]any{ |
| 187 | 209 | "Title": "Tags · " + row.Name, |
| 188 | 210 | "CSRFToken": middleware.CSRFTokenForRequest(r), |