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 Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· 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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -224,8 +224,8 @@ | |||
| 224 | 224 | </h2> | |
| 225 | 225 | <ul> | |
| 226 | 226 | <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"> </span>main</a> | |
| 229 | 229 | </li> | |
| 230 | 230 | <li> | |
| 231 | 231 | <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"> </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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -221,8 +221,8 @@ | |||
| 221 | 221 | </h2> | |
| 222 | 222 | <ul> | |
| 223 | 223 | <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"> </span>main</a> | |
| 226 | 226 | </li> | |
| 227 | 227 | <li> | |
| 228 | 228 | <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"> </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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -252,8 +252,8 @@ | |||
| 252 | 252 | </h2> | |
| 253 | 253 | <ul> | |
| 254 | 254 | <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"> </span>main</a> | |
| 257 | 257 | </li> | |
| 258 | 258 | <li> | |
| 259 | 259 | <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"> </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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -371,8 +371,8 @@ And <b>html</b> & "quotes".</pre> | |||
| 371 | 371 | </h2> | |
| 372 | 372 | <ul> | |
| 373 | 373 | <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"> </span>main</a> | |
| 376 | 376 | </li> | |
| 377 | 377 | <li> | |
| 378 | 378 | <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 <b>html</b> & "quotes".</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"> </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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -371,8 +371,8 @@ And <b>html</b> & "quotes".</pre> | |||
| 371 | 371 | </h2> | |
| 372 | 372 | <ul> | |
| 373 | 373 | <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"> </span>main</a> | |
| 376 | 376 | </li> | |
| 377 | 377 | <li> | |
| 378 | 378 | <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 <b>html</b> & "quotes".</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"> </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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -278,8 +278,8 @@ | |||
| 278 | 278 | </h2> | |
| 279 | 279 | <ul> | |
| 280 | 280 | <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"> </span>main</a> | |
| 283 | 283 | </li> | |
| 284 | 284 | <li> | |
| 285 | 285 | <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"> </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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -570,8 +570,8 @@ | |||
| 570 | 570 | </h2> | |
| 571 | 571 | <ul> | |
| 572 | 572 | <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"> </span>main</a> | |
| 575 | 575 | </li> | |
| 576 | 576 | <li> | |
| 577 | 577 | <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"> </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 @@ | |||
| 51 | 51 | </li> | |
| 52 | 52 | </ul> | |
| 53 | 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 | 55 | </button> | |
| 56 | 56 | </header> | |
| 57 | 57 | <div class="work has-rail"> | |
| @@ -387,8 +387,8 @@ | |||
| 387 | 387 | </h2> | |
| 388 | 388 | <ul> | |
| 389 | 389 | <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"> </span>main</a> | |
| 392 | 392 | </li> | |
| 393 | 393 | <li> | |
| 394 | 394 | <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"> </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, | |||
| 127 | 127 | ||
| 128 | 128 | l := s.repoLayout(ctx, d, "commits") | |
| 129 | 129 | 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 | 131 | history := repoHref(d.name()) | |
| 132 | 132 | if d.head != nil { | |
| 133 | 133 | 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.instance | 129 | 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) { | |||
| 232 | 232 | srv.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/-/events?topic=home", nil)) | |
| 233 | 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 | + | } | |
| @@ -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 | |||
| 99 | 99 | return gap, nil // no longer visible | |
| 100 | 100 | case err != nil: | |
| 101 | 101 | return nil, err | |
| 102 | - | case l.view == "summary": | |
| 102 | + | case l.view == "summary", l.view == "refs": | |
| 103 | 103 | return gap, nil // the description, the default branch | |
| 104 | 104 | } | |
| 105 | 105 | return nil, nil | |
| @@ -166,6 +166,11 @@ func (l *liveStream) banner(ctx context.Context, p *pb.Pushed) ([]fragment, erro | |||
| 166 | 166 | if err != nil { | |
| 167 | 167 | 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 | 174 | n, found := 0, false | |
| 170 | 175 | for _, c := range res.Msg.GetCommits() { | |
| 171 | 176 | 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 visible | 99 | return gap, nil // no longer visible | ||
| 100 | case err != nil: | 100 | case err != nil: | ||
| 101 | return nil, err | 101 | return nil, err | ||
| 102 | - | case l.view == "summary": | 102 | + | case l.view == "summary", l.view == "refs": |
| 103 | return gap, nil // the description, the default branch | 103 | return gap, nil // the description, the default branch | ||
| 104 | } | 104 | } | ||
| 105 | return nil, nil | 105 | 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, err | 167 | 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, false | 174 | 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 { | ||