patchbin
created pr with
patchbin/og-description.1
cmds
checkout latest patchset:
ssh pr.pico.sh pull patchbin:og-description | git am -3checkout specific patchset revision:
ssh pr.pico.sh pull patchbin:og-description [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh patchbin:og-descriptionadd comment to patch request:
ssh pr.pico.sh comment patchbin:og-description "lgtm!"
Patchset
patchbin/og-description.1
Include og:description
Stephen Paul Weber
2026-10-21T19:35:12ZIf 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 @@ | |
| 7 | 7 | title="RSS feed for {{.RepoName}}:{{.Pr.Slug}}" | |
| 8 | 8 | href="/{{.RepoName}}/{{.Pr.Slug}}/rss" /> | |
| 9 | 9 | <meta property="og:title" content="{{.Pr.Title}}" /> | |
| 10 | + | {{if .OgDescription}}<meta property="og:description" content="{{.OgDescription}}" />{{end}} | |
| 10 | 11 | <meta property="og:url" content="https://{{.MetaData.URL}}/{{.RepoName}}/{{.Pr.Slug}}" /> | |
| 11 | 12 | <meta property="og:type" content="object" /> | |
| 12 | 13 | <meta property="og:site_name" content="{{.MetaData.URL}}" /> |
+41
-0
web_pr_detail.go
#
| ... | ... | @@ -298,6 +300,44 @@ func getLogData(web *WebCtx, prID int64, patchsetsData []*PatchsetData) ([]Event | |
| 298 | 300 | return logData, nil | |
| 299 | 301 | } | |
| 300 | 302 | ||
| 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", " ")) | |
| 339 | + | } | |
| 340 | + | ||
| 301 | 341 | func createPrDetail(w http.ResponseWriter, r *http.Request) { | |
| 302 | 342 | web, err := getWebCtx(r) | |
| 303 | 343 | if err != nil { |