detached 3f267b5

fix(web): show the commit page as detached and reload the refs page on a repository update

The ref switcher of a commit page read main@<head> next to another
commit: it is now detached@<commit> with no ref marked current.

A change of the default branch makes the refs page stale as much as the
summary: both load themselves again on a RepoUpdated event.

Document that the new-commits count of the history banner is approximate.
commit
3f267b5d9f2f274e92ecbf83059928ba581804b4
author
brice · · 2026-10-10 14:24 UTC
parent
06a59c3
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
refs
tag: v0.1.0
11 files · +59 -26
M cmd/ermite/testdata/web/commit-big.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -224,8 +224,8 @@
224224 </h2>
225225 <ul>
226226 <li>
227-<a href="/diffs/tree/main" aria-current="true">
228-<span class="mark" aria-hidden="true">●</span>main</a>
227+<a href="/diffs/tree/main">
228+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
229229 </li>
230230 <li>
231231 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -224,8 +224,8 @@
224 </h2>224 </h2>
225 <ul>225 <ul>
226 <li>226 <li>
227-<a href="/diffs/tree/main" aria-current="true">227+<a href="/diffs/tree/main">
228-<span class="mark" aria-hidden="true">●</span>main</a>228+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
229 </li>229 </li>
230 <li>230 <li>
231 <a href="/diffs/tree/side">231 <a href="/diffs/tree/side">
M cmd/ermite/testdata/web/commit-binary.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -221,8 +221,8 @@
221221 </h2>
222222 <ul>
223223 <li>
224-<a href="/diffs/tree/main" aria-current="true">
225-<span class="mark" aria-hidden="true">●</span>main</a>
224+<a href="/diffs/tree/main">
225+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
226226 </li>
227227 <li>
228228 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -221,8 +221,8 @@
221 </h2>221 </h2>
222 <ul>222 <ul>
223 <li>223 <li>
224-<a href="/diffs/tree/main" aria-current="true">224+<a href="/diffs/tree/main">
225-<span class="mark" aria-hidden="true">●</span>main</a>225+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
226 </li>226 </li>
227 <li>227 <li>
228 <a href="/diffs/tree/side">228 <a href="/diffs/tree/side">
M cmd/ermite/testdata/web/commit-merge.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -252,8 +252,8 @@
252252 </h2>
253253 <ul>
254254 <li>
255-<a href="/diffs/tree/main" aria-current="true">
256-<span class="mark" aria-hidden="true">●</span>main</a>
255+<a href="/diffs/tree/main">
256+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
257257 </li>
258258 <li>
259259 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -252,8 +252,8 @@
252 </h2>252 </h2>
253 <ul>253 <ul>
254 <li>254 <li>
255-<a href="/diffs/tree/main" aria-current="true">255+<a href="/diffs/tree/main">
256-<span class="mark" aria-hidden="true">●</span>main</a>256+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
257 </li>257 </li>
258 <li>258 <li>
259 <a href="/diffs/tree/side">259 <a href="/diffs/tree/side">
M cmd/ermite/testdata/web/commit-modify-split.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -371,8 +371,8 @@ And &lt;b&gt;html&lt;/b&gt; &amp; &#34;quotes&#34;.</pre>
371371 </h2>
372372 <ul>
373373 <li>
374-<a href="/diffs/tree/main" aria-current="true">
375-<span class="mark" aria-hidden="true">●</span>main</a>
374+<a href="/diffs/tree/main">
375+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
376376 </li>
377377 <li>
378378 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -371,8 +371,8 @@ And &lt;b&gt;html&lt;/b&gt; &amp; &#34;quotes&#34;.</pre>
371 </h2>371 </h2>
372 <ul>372 <ul>
373 <li>373 <li>
374-<a href="/diffs/tree/main" aria-current="true">374+<a href="/diffs/tree/main">
375-<span class="mark" aria-hidden="true">●</span>main</a>375+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
376 </li>376 </li>
377 <li>377 <li>
378 <a href="/diffs/tree/side">378 <a href="/diffs/tree/side">
M cmd/ermite/testdata/web/commit-modify.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -371,8 +371,8 @@ And &lt;b&gt;html&lt;/b&gt; &amp; &#34;quotes&#34;.</pre>
371371 </h2>
372372 <ul>
373373 <li>
374-<a href="/diffs/tree/main" aria-current="true">
375-<span class="mark" aria-hidden="true">●</span>main</a>
374+<a href="/diffs/tree/main">
375+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
376376 </li>
377377 <li>
378378 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -371,8 +371,8 @@ And &lt;b&gt;html&lt;/b&gt; &amp; &#34;quotes&#34;.</pre>
371 </h2>371 </h2>
372 <ul>372 <ul>
373 <li>373 <li>
374-<a href="/diffs/tree/main" aria-current="true">374+<a href="/diffs/tree/main">
375-<span class="mark" aria-hidden="true">●</span>main</a>375+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
376 </li>376 </li>
377 <li>377 <li>
378 <a href="/diffs/tree/side">378 <a href="/diffs/tree/side">
M cmd/ermite/testdata/web/commit-rename.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -278,8 +278,8 @@
278278 </h2>
279279 <ul>
280280 <li>
281-<a href="/diffs/tree/main" aria-current="true">
282-<span class="mark" aria-hidden="true">●</span>main</a>
281+<a href="/diffs/tree/main">
282+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
283283 </li>
284284 <li>
285285 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -278,8 +278,8 @@
278 </h2>278 </h2>
279 <ul>279 <ul>
280 <li>280 <li>
281-<a href="/diffs/tree/main" aria-current="true">281+<a href="/diffs/tree/main">
282-<span class="mark" aria-hidden="true">●</span>main</a>282+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
283 </li>283 </li>
284 <li>284 <li>
285 <a href="/diffs/tree/side">285 <a href="/diffs/tree/side">
M cmd/ermite/testdata/web/commit-root.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -570,8 +570,8 @@
570570 </h2>
571571 <ul>
572572 <li>
573-<a href="/diffs/tree/main" aria-current="true">
574-<span class="mark" aria-hidden="true">●</span>main</a>
573+<a href="/diffs/tree/main">
574+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
575575 </li>
576576 <li>
577577 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -570,8 +570,8 @@
570 </h2>570 </h2>
571 <ul>571 <ul>
572 <li>572 <li>
573-<a href="/diffs/tree/main" aria-current="true">573+<a href="/diffs/tree/main">
574-<span class="mark" aria-hidden="true">●</span>main</a>574+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
575 </li>575 </li>
576 <li>576 <li>
577 <a href="/diffs/tree/side">577 <a href="/diffs/tree/side">
M cmd/ermite/testdata/web/commit-trojan.html +3 -3
@@ -51,7 +51,7 @@
5151 </li>
5252 </ul>
5353 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>
54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
5555 </button>
5656 </header>
5757 <div class="work has-rail">
@@ -387,8 +387,8 @@
387387 </h2>
388388 <ul>
389389 <li>
390-<a href="/diffs/tree/main" aria-current="true">
391-<span class="mark" aria-hidden="true">●</span>main</a>
390+<a href="/diffs/tree/main">
391+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
392392 </li>
393393 <li>
394394 <a href="/diffs/tree/side">
@@ -51,7 +51,7 @@
51 </li>51 </li>
52 </ul>52 </ul>
53 </nav>53 </nav>
54-<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">main<span class="sha">@SHA7</span>54+<button type="button" class="ref" aria-haspopup="dialog" aria-controls="panel-refs" aria-keyshortcuts="b" title="switch ref (b)" hx-on:click="document.body.dispatchEvent(new CustomEvent('k-refs'))">detached<span class="sha">@SHA7</span>
55 </button>55 </button>
56 </header>56 </header>
57 <div class="work has-rail">57 <div class="work has-rail">
@@ -387,8 +387,8 @@
387 </h2>387 </h2>
388 <ul>388 <ul>
389 <li>389 <li>
390-<a href="/diffs/tree/main" aria-current="true">390+<a href="/diffs/tree/main">
391-<span class="mark" aria-hidden="true">●</span>main</a>391+<span class="mark" aria-hidden="true">&nbsp;</span>main</a>
392 </li>392 </li>
393 <li>393 <li>
394 <a href="/diffs/tree/side">394 <a href="/diffs/tree/side">
M internal/adapters/web/commit.go +1 -1
@@ -127,7 +127,7 @@ func (s *Server) commit(ctx context.Context, r *http.Request) (templ.Component,
127127
128128 l := s.repoLayout(ctx, d, "commits")
129129 l.Title = p.Short + " " + p.Subject + " · " + d.name() + " · " + s.instance
130- l.SHA, l.RefPath = c.GetId(), ""
130+ pinRef(&l, target{rev: c.GetId(), name: p.Short, detached: true})
131131 history := repoHref(d.name())
132132 if d.head != nil {
133133 history = repoHref(d.name(), "commits", d.head.GetShortName())
@@ -127,7 +127,7 @@ func (s *Server) commit(ctx context.Context, r *http.Request) (templ.Component,
127 127
128 l := s.repoLayout(ctx, d, "commits")128 l := s.repoLayout(ctx, d, "commits")
129 l.Title = p.Short + " " + p.Subject + " · " + d.name() + " · " + s.instance129 l.Title = p.Short + " " + p.Subject + " · " + d.name() + " · " + s.instance
130- l.SHA, l.RefPath = c.GetId(), ""130+ pinRef(&l, target{rev: c.GetId(), name: p.Short, detached: true})
131 history := repoHref(d.name())131 history := repoHref(d.name())
132 if d.head != nil {132 if d.head != nil {
133 history = repoHref(d.name(), "commits", d.head.GetShortName())133 history = repoHref(d.name(), "commits", d.head.GetShortName())
M internal/adapters/web/events_test.go +28 -0
@@ -232,3 +232,31 @@ func TestEventsOffWithoutClient(t *testing.T) {
232232 srv.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/-/events?topic=home", nil))
233233 assert.Equal(t, http.StatusNotFound, rec.Code)
234234 }
235+
236+// A change of the repository (its default branch, say) makes the pages that
237+// show it load themselves again: the summary and the refs page, whose rows
238+// and marks depend on it. The commits page shows a branch, not the default.
239+func TestRepoUpdatedReloadsSummaryAndRefs(t *testing.T) {
240+ api := http.NewServeMux()
241+ api.Handle(ermiteconnect.NewRepoServiceHandler(repoOK{}))
242+ backend := httptest.NewServer(api)
243+ t.Cleanup(backend.Close)
244+ srv, err := New(Config{
245+ Repos: ermiteconnect.NewRepoServiceClient(backend.Client(), backend.URL),
246+ Git: ermiteconnect.NewGitServiceClient(backend.Client(), backend.URL),
247+ PublicURL: "https://forge.example",
248+ })
249+ require.NoError(t, err)
250+
251+ ev := &pb.Event{Kind: &pb.Event_RepoUpdated{RepoUpdated: &pb.RepoUpdated{Repo: &pb.Repo{Name: "x"}}}}
252+ for view, wantGap := range map[string]bool{"summary": true, "refs": true, "commits": false} {
253+ ls := &liveStream{s: srv, repo: "x", view: view}
254+ got, err := ls.render(t.Context(), ev)
255+ require.NoError(t, err, view)
256+ if wantGap {
257+ assert.Equal(t, gap, got, view)
258+ } else {
259+ assert.Empty(t, got, view)
260+ }
261+ }
262+}
@@ -232,3 +232,31 @@ func TestEventsOffWithoutClient(t *testing.T) {
232 srv.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/-/events?topic=home", nil))232 srv.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/-/events?topic=home", nil))
233 assert.Equal(t, http.StatusNotFound, rec.Code)233 assert.Equal(t, http.StatusNotFound, rec.Code)
234 }234 }
235+
236+// A change of the repository (its default branch, say) makes the pages that
237+// show it load themselves again: the summary and the refs page, whose rows
238+// and marks depend on it. The commits page shows a branch, not the default.
239+func TestRepoUpdatedReloadsSummaryAndRefs(t *testing.T) {
240+ api := http.NewServeMux()
241+ api.Handle(ermiteconnect.NewRepoServiceHandler(repoOK{}))
242+ backend := httptest.NewServer(api)
243+ t.Cleanup(backend.Close)
244+ srv, err := New(Config{
245+ Repos: ermiteconnect.NewRepoServiceClient(backend.Client(), backend.URL),
246+ Git: ermiteconnect.NewGitServiceClient(backend.Client(), backend.URL),
247+ PublicURL: "https://forge.example",
248+ })
249+ require.NoError(t, err)
250+
251+ ev := &pb.Event{Kind: &pb.Event_RepoUpdated{RepoUpdated: &pb.RepoUpdated{Repo: &pb.Repo{Name: "x"}}}}
252+ for view, wantGap := range map[string]bool{"summary": true, "refs": true, "commits": false} {
253+ ls := &liveStream{s: srv, repo: "x", view: view}
254+ got, err := ls.render(t.Context(), ev)
255+ require.NoError(t, err, view)
256+ if wantGap {
257+ assert.Equal(t, gap, got, view)
258+ } else {
259+ assert.Empty(t, got, view)
260+ }
261+ }
262+}
M internal/adapters/web/fragments.go +6 -1
@@ -99,7 +99,7 @@ func (l *liveStream) repoPage(ctx context.Context, ev *pb.Event) ([]fragment, er
9999 return gap, nil // no longer visible
100100 case err != nil:
101101 return nil, err
102- case l.view == "summary":
102+ case l.view == "summary", l.view == "refs":
103103 return gap, nil // the description, the default branch
104104 }
105105 return nil, nil
@@ -166,6 +166,11 @@ func (l *liveStream) banner(ctx context.Context, p *pb.Pushed) ([]fragment, erro
166166 if err != nil {
167167 return nil, err
168168 }
169+ // The count is approximate for a history with merges: the log is
170+ // ordered by date, not as "head..tip", so commits that are not new may
171+ // be counted before the head is met. And one page of the log being
172+ // all that is read, "100+" cannot be told from a rewritten branch
173+ // whose old head is further back: the API has no "is ancestor".
169174 n, found := 0, false
170175 for _, c := range res.Msg.GetCommits() {
171176 if c.GetId() == l.head {
@@ -99,7 +99,7 @@ func (l *liveStream) repoPage(ctx context.Context, ev *pb.Event) ([]fragment, er
99 return gap, nil // no longer visible99 return gap, nil // no longer visible
100 case err != nil:100 case err != nil:
101 return nil, err101 return nil, err
102- case l.view == "summary":102+ case l.view == "summary", l.view == "refs":
103 return gap, nil // the description, the default branch103 return gap, nil // the description, the default branch
104 }104 }
105 return nil, nil105 return nil, nil
@@ -166,6 +166,11 @@ func (l *liveStream) banner(ctx context.Context, p *pb.Pushed) ([]fragment, erro
166 if err != nil {166 if err != nil {
167 return nil, err167 return nil, err
168 }168 }
169+ // The count is approximate for a history with merges: the log is
170+ // ordered by date, not as "head..tip", so commits that are not new may
171+ // be counted before the head is met. And one page of the log being
172+ // all that is read, "100+" cannot be told from a rewritten branch
173+ // whose old head is further back: the API has no "is ancestor".
169 n, found := 0, false174 n, found := 0, false
170 for _, c := range res.Msg.GetCommits() {175 for _, c := range res.Msg.GetCommits() {
171 if c.GetId() == l.head {176 if c.GetId() == l.head {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 42

↑↓ moveenter openesc close