Commit e0a00fbaee

e0a00fbaee928be79f797f86ddd2e97e04d5fa96

parent: f4f897ed47

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-28 21:41 UTC

web: list each MR revision with a compare-to-previous link

Ref #269

Layout: unified · split

internal/httpd/mrpage_test.go +25
@@ -199,3 +199,28 @@ func TestMRGatesRender(t *testing.T) {
199199 t.Errorf("gates block on a merge request without gates:\n%s", out)
200200 }
201201}
202
203// Each revision after the first carries a link comparing it to the one
204// before, so a reviewer does not have to type mr range-diff by hand
205// (#269).
206func TestMRPageListsRevisionsWithCompareLinks(t *testing.T) {
207 var sb strings.Builder
208 revs := []store.MRHead{
209 {SHA: "aaaa1111", CreatedAt: "2026-09-23T10:00:00Z"},
210 {SHA: "bbbb2222", CreatedAt: "2026-09-24T10:00:00Z"},
211 }
212 if err := web.Render(&sb, "mr.html", mrPageData{
213 repoPage: testRepoPage(), MR: testMR("open"), View: "conversation", Revisions: revs,
214 }); err != nil {
215 t.Fatalf("render: %v", err)
216 }
217 out := sb.String()
218 for _, want := range []string{"aaaa1111", "bbbb2222", "compare to previous", "from=aaaa1111", "to=bbbb2222"} {
219 if !strings.Contains(out, want) {
220 t.Errorf("missing %q in:\n%s", want, out)
221 }
222 }
223 if strings.Contains(out, "gitbay mr range-diff") {
224 t.Error("still quotes the CLI command instead of linking the new page")
225 }
226}
internal/web/templates/mr.html +5 −2
@@ -134,9 +134,12 @@
134134 <h2>Reviews</h2>
135135 {{range .Reviews}}<p class="row"><span class="dot {{if eq .Verdict "approve"}}ok{{else}}pend{{end}}"></span><a href="/{{.Reviewer}}">{{.Reviewer}}</a> {{.Verdict}}{{if .Stale}} <span class="chip chip-stale">stale</span>{{end}}{{if not .Counts}} <span class="chip chip-neutral" title="This reviewer has no write access, so the merge gates do not count it">advisory</span>{{end}}<span class="sub">{{when .CreatedAt}}</span></p>
136136 {{else}}<p class="none">none yet</p>{{end}}
137 {{if gt (len .Revisions) 1}}<p class="row none">{{len .Revisions}} revisions pushed. What changed between the last two:
138 <code>gitbay mr range-diff {{.Repo.OwnerName}}/{{.Repo.Name}} {{.MR.Number}}</code></p>{{end}}
139137 </div>
138 {{if .Revisions}}<div class="grp">
139 <h2>Revisions</h2>
140 {{range $i, $rv := .Revisions}}<p class="row none">{{add $i 1}}. <code>{{short $rv.SHA}}</code> {{when $rv.CreatedAt}}{{if $i}} · <a href="{{$base}}/range-diff?from={{(index $.Revisions (sub $i 1)).SHA}}&amp;to={{$rv.SHA}}">compare to previous</a>{{end}}</p>
141 {{end}}
142 </div>{{end}}
140143 <div class="grp">
141144 <h2>Reviewers</h2>
142145 {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p>