main git-pr / tmpl / components / patch-detail.html
Eric Bower  ·  2026-02-25
 1{{define "patch-detail"}}
 2<div class="w-full flex-1" style="min-width: 0;">
 3  <div class="group" id="{{.Patch.Url}}">
 4    <div class="box border-visited flex justify-between items-center" id="{{.Patch.ID}}">
 5      <a href="#patch-{{.Patch.ID}}">{{.Patch.Title}}</a>
 6      <div>{{.Patch.AuthorName}} <code>{{.Patch.FormattedAuthorDate}}</code></div>
 7    </div>
 8    {{if .Patch.Body}}<pre class="w-full">{{.Patch.Body}}</pre>{{end}}
 9
10    {{if .Patch.SemanticSummary.HasContent}}
11    {{template "semantic-summary" .Patch}}
12    {{end}}
13  </div>
14</div>
15{{end}}
16
17{{define "patch-files"}}
18<div class="group">
19  {{range .Patch.PatchFiles}}
20    {{template "patch-file" .}}
21  {{end}}
22</div>
23
24<div><a href="#top" class="text-sm">Back to top</a></div>
25{{end}}
26
27{{define "semantic-summary"}}
28{{$summary := .SemanticSummary}}
29<details class="details-min semantic-summary" open>
30  <summary class="font-bold">Semantic diff summary</summary>
31  <div class="semantic-summary-totals text-sm">
32    <span class="semantic-diff-added-text">{{$summary.Added}} added</span>,
33    <span class="semantic-diff-modified-text">{{$summary.Modified}} modified</span>,
34    <span class="semantic-diff-signature_changed-text">{{$summary.SignatureChanged}} signature changed</span>,
35    <span class="semantic-diff-removed-text">{{$summary.Removed}} removed</span>
36    across {{$summary.AnalyzedFileCount}} analyzed file{{if ne $summary.AnalyzedFileCount 1}}s{{end}}
37    {{if $summary.SkippedFiles}}({{len $summary.SkippedFiles}} file{{if ne (len $summary.SkippedFiles) 1}}s{{end}} skipped: unsupported file type){{end}}
38  </div>
39  {{range .PatchFiles}}
40    {{if .SemanticChanges}}
41    <div class="semantic-summary-file">
42      <a href="#{{.FileAnchor}}" class="mono">{{.DisplayName}}</a>
43      <ul class="semantic-diff">
44        {{range .SemanticChanges}}
45        <li class="semantic-diff-{{.Kind}}">
46          <a href="#{{.HunkAnchor}}" class="semantic-diff-link" data-open-details="1">
47            <code class="semantic-diff-entity-kind">{{.EntityKind}}</code>
48            <code class="mono">{{.Name}}</code>
49            {{if eq (print .Kind) "added"}}added
50            {{else if eq (print .Kind) "removed"}}removed
51            {{else if eq (print .Kind) "signature_changed"}}signature changed
52            {{else}}modified
53            {{end}}
54          </a>
55        </li>
56        {{end}}
57      </ul>
58    </div>
59    {{end}}
60  {{end}}
61</details>
62{{end}}
63
64{{define "patch-file"}}
65<details class="details-min" id="{{.FileAnchor}}">
66  <summary class="patch-file">
67    <code class="pill-success">+{{.Adds}}</code>
68    <code class="pill-admin">-{{.Dels}}</code>
69    <span class="mono ml">{{.DisplayName}}</span>
70    <a href="#{{.FileAnchor}}" class="file-link" title="link to file">#</a>
71  </summary>
72  {{if .IsBinary}}
73  <div class="w-full"><pre>Binaries are not rendered as diffs.</pre></div>
74  {{else}}
75    {{range .Hunks}}
76    <div class="w-full" id="{{.Anchor}}">{{.DiffText}}</div>
77    {{end}}
78  {{end}}
79</details>
80{{end}}