Commit d05948b

Nick Faro committed on
Match GitHub commit attribution
commit d05948b605179a8e87859496df7b8f1aee26711c parent 05d4b5b
4 changed files +52−38
Modifiedinternal/site/metadata.go +28−17
@@ -83,7 +83,7 @@ func (g *Generator) branchSummary(ctx context.Context, branch, oid string) (bran
83 } 83 }
84 84
85 func (g *Generator) commits(ctx context.Context, oid string) ([]Commit, error) { 85 func (g *Generator) commits(ctx context.Context, oid string) ([]Commit, error) {
86 out, err := g.Git.Run(ctx, "log", "--format=%H%x00%h%x00%an%x00%ae%x00%aI%x00%s%x00%b%x00%P%x00", oid) 86 out, err := g.Git.Run(ctx, "log", "--format=%H%x00%h%x00%an%x00%ae%x00%aI%x00%cn%x00%ce%x00%cI%x00%s%x00%b%x00%P%x00", oid)
87 if err != nil { 87 if err != nil {
88 return nil, err 88 return nil, err
89 } 89 }
@@ -91,32 +91,43 @@ func (g *Generator) commits(ctx context.Context, oid string) ([]Commit, error) {
91 if len(fields) > 0 && strings.TrimSpace(fields[len(fields)-1]) == "" { 91 if len(fields) > 0 && strings.TrimSpace(fields[len(fields)-1]) == "" {
92 fields = fields[:len(fields)-1] 92 fields = fields[:len(fields)-1]
93 } 93 }
94 if len(fields)%8 != 0 { 94 if len(fields)%11 != 0 {
95 return nil, fmt.Errorf("unexpected git log output") 95 return nil, fmt.Errorf("unexpected git log output")
96 } 96 }
97 result := make([]Commit, 0, len(fields)/8) 97 result := make([]Commit, 0, len(fields)/11)
98 for i := 0; i < len(fields); i += 8 { 98 for i := 0; i < len(fields); i += 11 {
99 author := strings.TrimSpace(fields[i+2]) 99 author := strings.TrimSpace(fields[i+2])
100 email := strings.TrimSpace(fields[i+3]) 100 email := strings.TrimSpace(fields[i+3])
101 dateTime := strings.TrimSpace(fields[i+4]) 101 committer := strings.TrimSpace(fields[i+5])
102 committerEmail := strings.TrimSpace(fields[i+6])
103 dateTime := strings.TrimSpace(fields[i+7])
102 result = append(result, Commit{ 104 result = append(result, Commit{
103 OID: strings.TrimSpace(fields[i]), 105 OID: strings.TrimSpace(fields[i]),
104 ShortOID: strings.TrimSpace(fields[i+1]), 106 ShortOID: strings.TrimSpace(fields[i+1]),
105 Author: author, 107 Author: author,
106 Email: email, 108 Email: email,
107 Date: displayDate(dateTime), 109 Committer: committer,
108 DateTime: dateTime, 110 CommitterEmail: committerEmail,
109 Message: strings.TrimSpace(fields[i+5]), 111 Date: displayDate(dateTime),
110 Body: strings.TrimSpace(fields[i+6]), 112 DateTime: dateTime,
111 Initials: initials(author), 113 Message: strings.TrimSpace(fields[i+8]),
112 AvatarURL: gravatarURL(email, author), 114 Body: strings.TrimSpace(fields[i+9]),
113 URL: routeURL(g.BaseURL, path.Join("commit", strings.TrimSpace(fields[i]))), 115 Initials: initials(author),
114 Parents: strings.Fields(fields[i+7]), 116 AvatarURL: gravatarURL(email, author),
117 CommitterAvatarURL: gravatarURL(committerEmail, committer),
118 DistinctCommitter: !sameCommitIdentity(author, email, committer, committerEmail),
119 URL: routeURL(g.BaseURL, path.Join("commit", strings.TrimSpace(fields[i]))),
120 Parents: strings.Fields(fields[i+10]),
115 }) 121 })
116 } 122 }
117 return result, nil 123 return result, nil
118 } 124 }
119 125
126 func sameCommitIdentity(author, authorEmail, committer, committerEmail string) bool {
127 return strings.EqualFold(strings.TrimSpace(author), strings.TrimSpace(committer)) &&
128 strings.EqualFold(strings.TrimSpace(authorEmail), strings.TrimSpace(committerEmail))
129 }
130
120 func groupCommits(commits []Commit) []CommitGroup { 131 func groupCommits(commits []Commit) []CommitGroup {
121 var groups []CommitGroup 132 var groups []CommitGroup
122 for _, commit := range commits { 133 for _, commit := range commits {
Modifiedinternal/site/site.go +16−12
@@ -65,18 +65,22 @@ type Generator struct {
65 } 65 }
66 66
67 type Commit struct { 67 type Commit struct {
68 OID string 68 OID string
69 ShortOID string 69 ShortOID string
70 Author string 70 Author string
71 Email string 71 Email string
72 Date string 72 Committer string
73 DateTime string 73 CommitterEmail string
74 Message string 74 Date string
75 Body string 75 DateTime string
76 Initials string 76 Message string
77 AvatarURL string 77 Body string
78 URL string 78 Initials string
79 Parents []string 79 AvatarURL string
80 CommitterAvatarURL string
81 DistinctCommitter bool
82 URL string
83 Parents []string
80 } 84 }
81 85
82 type TreeEntry struct { 86 type TreeEntry struct {
Modifiedinternal/site/style.go +6−5
@@ -277,16 +277,16 @@ button, input { font: inherit; }
277 .commit-group { margin: 0 0 28px; } 277 .commit-group { margin: 0 0 28px; }
278 .commit-group > h2 { margin: 0 0 9px; font-size: 15px; font-weight: 600; } 278 .commit-group > h2 { margin: 0 0 9px; font-size: 15px; font-weight: 600; }
279 .commit-list { overflow: hidden; border: 1px solid var(--border); border-radius: 7px; } 279 .commit-list { overflow: hidden; border: 1px solid var(--border); border-radius: 7px; }
280 .commit-list-row { min-height: 67px; display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 10px 14px; border-top: 1px solid var(--border-muted); } 280 .commit-list-row { min-height: 67px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 10px 14px; border-top: 1px solid var(--border-muted); }
281 .commit-list-row:first-child { border-top: 0; } 281 .commit-list-row:first-child { border-top: 0; }
282 .commit-list-row:target { background: var(--attention-bg); } 282 .commit-list-row:target { background: var(--attention-bg); }
283 .commit-list-row:hover { background: var(--canvas); } 283 .commit-list-row:hover { background: var(--canvas); }
284 .commit-list-row:target:hover { background: var(--attention-bg); } 284 .commit-list-row:target:hover { background: var(--attention-bg); }
285 .commit-list-row .commit-avatar { width: 34px; height: 34px; }
286 .commit-list-body { min-width: 0; display: flex; flex-direction: column; } 285 .commit-list-body { min-width: 0; display: flex; flex-direction: column; }
287 .commit-list-message { overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; } 286 .commit-list-message { overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
288 .commit-list-message:hover, .commit-list-message:focus { color: var(--text); text-decoration: underline; } 287 .commit-list-message:hover, .commit-list-message:focus { color: var(--text); text-decoration: underline; }
289 .commit-list-body > span { color: var(--muted); font-size: 12px; } 288 .commit-list-body > span { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
289 .commit-list-avatar { width: 16px; height: 16px; }
290 .commit-list-body > span strong { color: var(--text); } 290 .commit-list-body > span strong { color: var(--text); }
291 .commit-list-actions { display: inline-flex; align-items: center; gap: 6px; } 291 .commit-list-actions { display: inline-flex; align-items: center; gap: 6px; }
292 .commit-sha { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: var(--canvas); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; } 292 .commit-sha { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: var(--canvas); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
@@ -305,7 +305,8 @@ button, input { font: inherit; }
305 .commit-copy.is-copied { color: var(--green); background: var(--success-bg); } 305 .commit-copy.is-copied { color: var(--green); background: var(--success-bg); }
306 .commit-body { margin: 0; padding: 14px 16px; overflow: auto; border-bottom: 1px solid var(--border-muted); color: var(--text); background: var(--bg); font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; } 306 .commit-body { margin: 0; padding: 14px 16px; overflow: auto; border-bottom: 1px solid var(--border-muted); color: var(--text); background: var(--bg); font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
307 .commit-author-row { min-height: 28px; margin: -6px 0 12px; display: flex; align-items: center; gap: 9px; } 307 .commit-author-row { min-height: 28px; margin: -6px 0 12px; display: flex; align-items: center; gap: 9px; }
308 .commit-author-row > span { color: var(--muted); } 308 .commit-author-row > span { display: flex; align-items: center; gap: 5px; color: var(--muted); }
309 .commit-author-row .commit-avatar { width: 20px; height: 20px; }
309 .commit-author-row strong { color: var(--text); } 310 .commit-author-row strong { color: var(--text); }
310 .commit-identifiers { min-height: 48px; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; color: var(--muted); font-size: 12px; } 311 .commit-identifiers { min-height: 48px; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; color: var(--muted); font-size: 12px; }
311 .commit-identifiers code { color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; } 312 .commit-identifiers code { color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
@@ -392,7 +393,7 @@ button, input { font: inherit; }
392 .row-message { display: none; } 393 .row-message { display: none; }
393 .markdown-body { padding: 22px 18px; } 394 .markdown-body { padding: 22px 18px; }
394 .branch-popover, .clone-popover { position: fixed; top: 74px; left: 12px; right: 12px; width: auto; } 395 .branch-popover, .clone-popover { position: fixed; top: 74px; left: 12px; right: 12px; width: auto; }
395 .commit-list-row { grid-template-columns: 34px minmax(0,1fr); } 396 .commit-list-row { grid-template-columns: minmax(0,1fr); }
396 .commit-list-actions { display: none; } 397 .commit-list-actions { display: none; }
397 .commit-summary-title { align-items: center; } 398 .commit-summary-title { align-items: center; }
398 .commit-page-heading h1 { font-size: 20px; } 399 .commit-page-heading h1 { font-size: 20px; }
Modifiedinternal/site/template.go +2−4
@@ -105,10 +105,9 @@ const pageTemplate = `<!doctype html>
105 <h2>Commits on {{.Date}}</h2> 105 <h2>Commits on {{.Date}}</h2>
106 <div class="commit-list"> 106 <div class="commit-list">
107 {{range .Commits}}<article class="commit-list-row" id="{{.OID}}"> 107 {{range .Commits}}<article class="commit-list-row" id="{{.OID}}">
108 <img class="avatar commit-avatar" src="{{.AvatarURL}}" alt="" loading="lazy" referrerpolicy="no-referrer">
109 <div class="commit-list-body"> 108 <div class="commit-list-body">
110 <a class="commit-list-message" href="{{.URL}}">{{.Message}}</a> 109 <a class="commit-list-message" href="{{.URL}}">{{.Message}}</a>
111 <span><strong>{{.Author}}</strong> committed on <time datetime="{{.DateTime}}" data-smart-time>{{.Date}}</time></span> 110 <span><img class="avatar commit-list-avatar" src="{{.AvatarURL}}" alt="" loading="lazy" referrerpolicy="no-referrer"><strong>{{.Author}}</strong>{{if .DistinctCommitter}} authored and <img class="avatar commit-list-avatar" src="{{.CommitterAvatarURL}}" alt="" loading="lazy" referrerpolicy="no-referrer"><strong>{{.Committer}}</strong>{{end}} committed on <time datetime="{{.DateTime}}" data-smart-time>{{.Date}}</time></span>
112 </div> 111 </div>
113 <div class="commit-list-actions"> 112 <div class="commit-list-actions">
114 <a class="commit-sha" href="{{.URL}}">{{.ShortOID}}</a> 113 <a class="commit-sha" href="{{.URL}}">{{.ShortOID}}</a>
@@ -122,8 +121,7 @@ const pageTemplate = `<!doctype html>
122 <section class="primary full-width commit-view"> 121 <section class="primary full-width commit-view">
123 <div class="commit-page-heading"><h1>Commit <code>{{.ViewedCommit.Commit.ShortOID}}</code></h1></div> 122 <div class="commit-page-heading"><h1>Commit <code>{{.ViewedCommit.Commit.ShortOID}}</code></h1></div>
124 <div class="commit-author-row"> 123 <div class="commit-author-row">
125 <img class="avatar commit-avatar" src="{{.ViewedCommit.Commit.AvatarURL}}" alt="" referrerpolicy="no-referrer"> 124 <span><img class="avatar commit-avatar" src="{{.ViewedCommit.Commit.AvatarURL}}" alt="" referrerpolicy="no-referrer"><strong>{{.ViewedCommit.Commit.Author}}</strong>{{if .ViewedCommit.Commit.DistinctCommitter}} authored and <img class="avatar commit-avatar" src="{{.ViewedCommit.Commit.CommitterAvatarURL}}" alt="" referrerpolicy="no-referrer"><strong>{{.ViewedCommit.Commit.Committer}}</strong>{{end}} committed on <time datetime="{{.ViewedCommit.Commit.DateTime}}" data-smart-time>{{.ViewedCommit.Commit.Date}}</time></span>
126 <span><strong>{{.ViewedCommit.Commit.Author}}</strong> committed on <time datetime="{{.ViewedCommit.Commit.DateTime}}" data-smart-time>{{.ViewedCommit.Commit.Date}}</time></span>
127 </div> 125 </div>
128 <article class="commit-summary-card"> 126 <article class="commit-summary-card">
129 <div class="commit-summary-title"> 127 <div class="commit-summary-title">