patchbin

created pr with patchbin/og-description.1 on 2026-10-21T19:38:25Z · by 9e834e0d
cmds
checkout latest patchset:
ssh pr.pico.sh pull patchbin:og-description | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull patchbin:og-description [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh patchbin:og-description
add comment to patch request:
ssh pr.pico.sh comment patchbin:og-description "lgtm!"

Patchset patchbin/og-description.1 on 2026-10-21T19:38:25Z · commit 4228e54

Include og:description
Stephen Paul Weber 2026-10-21T19:35:12Z
If there are multiple patches, use all the titles as the description
If there is one commit, use the patch title+body for the description
If the PR title is the title of a patch, exclude that from the description

Use HTML entity to put newlines in the description.
Semantic diff summary
2 added, 3 modified, 0 signature changed, 0 removed across 1 analyzed file (1 file skipped: unsupported file type)
+1 -0 tmpl/pages/pr.html #
......@@ -7,6 +7,7 @@
77 title="RSS feed for {{.RepoName}}:{{.Pr.Slug}}"
88 href="/{{.RepoName}}/{{.Pr.Slug}}/rss" />
99 <meta property="og:title" content="{{.Pr.Title}}" />
10+{{if .OgDescription}}<meta property="og:description" content="{{.OgDescription}}" />{{end}}
1011 <meta property="og:url" content="https://{{.MetaData.URL}}/{{.RepoName}}/{{.Pr.Slug}}" />
1112 <meta property="og:type" content="object" />
1213 <meta property="og:site_name" content="{{.MetaData.URL}}" />
+41 -0 web_pr_detail.go #
......@@ -2,6 +2,7 @@ package patchbin
22
33 import (
44 "fmt"
5+ "html"
56 "html/template"
67 "net/http"
78 "slices"
......@@ -90,6 +91,7 @@ type PrDetailData struct {
9091 PrevUrl string
9192 NextUrl string
9293 Logs []EventLogData
94+ OgDescription template.HTML
9395 MetaData
9496 }
9597
......@@ -298,6 +300,44 @@ func getLogData(web *WebCtx, prID int64, patchsetsData []*PatchsetData) ([]Event
298300 return logData, nil
299301 }
300302
303+func ogDescriptionForPatches(patches []PatchSummary, prTitle string) string {
304+ if len(patches) == 1 {
305+ msg := ""
306+ if patches[0].Title != prTitle {
307+ msg = patches[0].Title
308+ if patches[0].Body != "" {
309+ msg += "\n\n"
310+ }
311+ }
312+ if patches[0].Body != "" {
313+ msg += patches[0].Body
314+ }
315+ return strings.TrimSpace(msg)
316+ }
317+
318+ var titles []string
319+ for _, p := range patches {
320+ if p.Title != prTitle {
321+ titles = append(titles, p.Title)
322+ }
323+ }
324+
325+ if len(titles) == 0 {
326+ return ""
327+ }
328+
329+ return strings.Join(titles, "\n")
330+}
331+
332+func ogDescriptionHTML(patches []PatchSummary, prTitle string) template.HTML {
333+ desc := ogDescriptionForPatches(patches, prTitle)
334+ if desc == "" {
335+ return ""
336+ }
337+ escaped := html.EscapeString(desc)
338+ return template.HTML(strings.ReplaceAll(escaped, "\n", "&#10;"))
339+}
340+
301341 func createPrDetail(w http.ResponseWriter, r *http.Request) {
302342 web, err := getWebCtx(r)
303343 if err != nil {
......@@ -465,6 +505,7 @@ func createPrDetail(w http.ResponseWriter, r *http.Request) {
465505 PrevUrl: prevUrl,
466506 NextUrl: nextUrl,
467507 Logs: logData,
508+ OgDescription: ogDescriptionHTML(aps.Patches, pr.Name),
468509 Pr: PrData{
469510 ID: pr.ID,
470511 Slug: pr.Slug,
Back to top