repos / git-pr

a self-hosted git collaboration server
git clone https://github.com/picosh/git-pr.git

commit
859f6cb
parent
a8b145e
author
Eric Bower
date
2025-12-13 12:53:38 -0500 EST
feat: show auth and commit info for range diff
2 files changed,  +72, -12
M range_diff.go
+38, -6
 1@@ -294,12 +294,23 @@ func outputRemovedPatch(patch *PatchRange) []*RangeDiffFile {
 2 
 3 // RangeDiffHeader is a header combining old and new change pairs.
 4 type RangeDiffHeader struct {
 5-	OldIdx       int
 6-	OldSha       string
 7-	NewIdx       int
 8-	NewSha       string
 9-	Title        string
10-	ContentEqual bool
11+	OldIdx         int
12+	OldSha         string
13+	OldAuthorName  string
14+	OldAuthorEmail string
15+	OldTitle       string
16+	OldBody        string
17+	NewIdx         int
18+	NewSha         string
19+	NewAuthorName  string
20+	NewAuthorEmail string
21+	NewTitle       string
22+	NewBody        string
23+	Title          string
24+	ContentEqual   bool
25+	AuthorChanged  bool
26+	TitleChanged   bool
27+	BodyChanged    bool
28 }
29 
30 func NewRangeDiffHeader(a *PatchRange, b *PatchRange, aIndex, bIndex int) *RangeDiffHeader {
31@@ -307,12 +318,20 @@ func NewRangeDiffHeader(a *PatchRange, b *PatchRange, aIndex, bIndex int) *Range
32 	if a == nil {
33 		hdr.NewIdx = bIndex
34 		hdr.NewSha = b.CommitSha
35+		hdr.NewAuthorName = b.AuthorName
36+		hdr.NewAuthorEmail = b.AuthorEmail
37+		hdr.NewTitle = b.Title
38+		hdr.NewBody = b.Body
39 		hdr.Title = b.Title
40 		return hdr
41 	}
42 	if b == nil {
43 		hdr.OldIdx = aIndex
44 		hdr.OldSha = a.CommitSha
45+		hdr.OldAuthorName = a.AuthorName
46+		hdr.OldAuthorEmail = a.AuthorEmail
47+		hdr.OldTitle = a.Title
48+		hdr.OldBody = a.Body
49 		hdr.Title = a.Title
50 		return hdr
51 	}
52@@ -321,6 +340,19 @@ func NewRangeDiffHeader(a *PatchRange, b *PatchRange, aIndex, bIndex int) *Range
53 	hdr.NewIdx = bIndex
54 	hdr.OldSha = a.CommitSha
55 	hdr.NewSha = b.CommitSha
56+	hdr.OldAuthorName = a.AuthorName
57+	hdr.OldAuthorEmail = a.AuthorEmail
58+	hdr.OldTitle = a.Title
59+	hdr.OldBody = a.Body
60+	hdr.NewAuthorName = b.AuthorName
61+	hdr.NewAuthorEmail = b.AuthorEmail
62+	hdr.NewTitle = b.Title
63+	hdr.NewBody = b.Body
64+
65+	// Check what changed
66+	hdr.AuthorChanged = a.AuthorName != b.AuthorName || a.AuthorEmail != b.AuthorEmail
67+	hdr.TitleChanged = a.Title != b.Title
68+	hdr.BodyChanged = a.Body != b.Body
69 
70 	if a.ContentSha == b.ContentSha {
71 		hdr.Title = a.Title
M tmpl/components/range-diff.html
+34, -6
 1@@ -53,6 +53,34 @@
 2               </code>
 3             </div>
 4 
 5+            {{if or .Header.AuthorChanged .Header.TitleChanged .Header.BodyChanged}}
 6+            <div class="box mb">
 7+              <dl>
 8+                {{if .Header.AuthorChanged}}
 9+                <dt>author changed</dt>
10+                <dd>
11+                  <div><span style="color: tomato;">- {{.Header.OldAuthorName}} &lt;{{.Header.OldAuthorEmail}}&gt;</span></div>
12+                  <div><span style="color: limegreen;">+ {{.Header.NewAuthorName}} &lt;{{.Header.NewAuthorEmail}}&gt;</span></div>
13+                </dd>
14+                {{end}}
15+                {{if .Header.TitleChanged}}
16+                <dt>title changed</dt>
17+                <dd>
18+                  <div><span style="color: tomato;">- {{.Header.OldTitle}}</span></div>
19+                  <div><span style="color: limegreen;">+ {{.Header.NewTitle}}</span></div>
20+                </dd>
21+                {{end}}
22+                {{if .Header.BodyChanged}}
23+                <dt>message changed</dt>
24+                <dd>
25+                  <pre style="color: tomato; margin: 0;">- {{.Header.OldBody}}</pre>
26+                  <pre style="color: limegreen; margin: 0;">+ {{.Header.NewBody}}</pre>
27+                </dd>
28+                {{end}}
29+              </dl>
30+            </div>
31+            {{end}}
32+
33             <div>
34               {{- if .Files -}}
35                 {{range .Files}}
36@@ -68,11 +96,11 @@
37                       <pre class="m-0">{{- range .Diff -}}
38                         {{- if eq .OuterType "delete" -}}
39                           {{- if eq .InnerType "insert" -}}
40-                            <span style="background-color: tomato; color: limegreen;">{{.Text}}</span>
41+                            <span style="background-color: rgba(255,99,71,0.25); color: limegreen;">{{.Text}}</span>
42                           {{- else if eq .InnerType "delete" -}}
43-                            <span style="background-color: tomato; color: #8B0000;">{{.Text}}</span>
44+                            <span style="background-color: rgba(255,99,71,0.25); color: tomato;">{{.Text}}</span>
45                           {{- else -}}
46-                            <span style="background-color: tomato;">{{.Text}}</span>
47+                            <span style="background-color: rgba(255,99,71,0.25);">{{.Text}}</span>
48                           {{- end -}}
49                         {{- else if eq .OuterType "insert" -}}
50                         {{- else if eq .InnerType "insert" -}}
51@@ -96,11 +124,11 @@
52                       <pre class="m-0">{{- range .Diff -}}
53                         {{- if eq .OuterType "insert" -}}
54                           {{- if eq .InnerType "insert" -}}
55-                            <span style="background-color: limegreen; color: #006400;">{{.Text}}</span>
56+                            <span style="background-color: rgba(50,205,50,0.25); color: limegreen;">{{.Text}}</span>
57                           {{- else if eq .InnerType "delete" -}}
58-                            <span style="background-color: limegreen; color: tomato;">{{.Text}}</span>
59+                            <span style="background-color: rgba(50,205,50,0.25); color: tomato;">{{.Text}}</span>
60                           {{- else -}}
61-                            <span style="background-color: limegreen;">{{.Text}}</span>
62+                            <span style="background-color: rgba(50,205,50,0.25);">{{.Text}}</span>
63                           {{- end -}}
64                         {{- else if eq .OuterType "delete" -}}
65                         {{- else if eq .InnerType "insert" -}}