Public: anyone can read this; the crew can change it.

A backup card for branches whose commits are missing links each branch to its delete, so the repository's owner settles it in one confirmed tap #12618

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/12612-a-backup-card-for-branches-whose-commits → main 15 commits fork 4 threads · 4 unresolved

  • Merged. scout/12612-a-backup-card-for-branches-whose-commits was merged into main as e56825c.

Review

Sign in to review this change.
12 files changed +290 −28
docs/features/backup-refs.md +7 −3
@@ -7,11 +7,15 @@ and names that branch. The forge's admin then sees one card for each such
77 repository, on the vitals and the home:
88
99 > 1 branch of owner/name cannot be backed up: their commits are missing (name).
10 > The rest of the repository is in the snapshot. Delete it on its Branches page.
10 > The rest of the repository is in the snapshot. Re-push each from a clone that
11 > still has its commits, or delete it on the branches page; the repository's
12 > owner or a writer can.
1113
1214 **To clear it:** open the card. It links to the repository's Branches page,
13 `/owner/name/branches`. A writer there presses *Delete* on the branch the card
14 names. Pushing the branch again from a clone that has every object also works.
15 `/owner/name/branches`, and each branch it names links to its own row there
16 (`#branch-<name>`). The owner or a writer presses *Delete* on that row. Pushing
17 the branch again from a clone that has every object also works. A site admin
18 writes every repository, so the admin who reads the card can press it too.
1519 The card goes away when the next snapshot lands without the branch.
1620
1721 - **The commits stay.** Deleting the branch removes only the ref. The forge
src/actions/health.ts +14 −1
@@ -182,6 +182,9 @@ export interface ForgeNeed {
182182 readonly line: string;
183183 /** Where to look into it. */
184184 readonly href: string;
185 /** The repository it is about, and a link each for what in it to act on (`Degraded`). */
186 readonly repo?: string;
187 readonly links?: NonNullable<Degraded["links"]>;
185188 }
186189
187190 const HEALTH_HREF = "/api/v1/health";
@@ -205,7 +208,7 @@ export function forgeNeedList(app: App, actor: User | undefined): ForgeNeed[] |
205208 ...(rollout === null ? [] : [{ cause: "rollout", line: rollout, href: HEALTH_HREF }]),
206209 ...engineNeed(app.config.engine),
207210 ...h.incidents.map((i) => ({ cause: `incident:${i.key}`, line: `${i.key}: ${i.message}`, href: HEALTH_HREF })),
208 ...h.degraded.map((d) => ({ cause: d.cause, line: needLine(d), href: d.href })),
211 ...h.degraded.map((d): ForgeNeed => ({ cause: d.cause, line: needLine(d), href: d.href, ...(d.repo === undefined || d.links === undefined ? {} : { repo: d.repo, links: d.links }) })),
209212 ...flakeForgeNeeds(h.flakes),
210213 ...(ledger === null ? [] : [{ cause: "ledger", line: ledger, href: HEALTH_HREF }]),
211214 ];
@@ -247,6 +250,16 @@ export function forgeNeeds(app: App, actor: User | undefined): string[] | undefi
247250
248251 export { sinceWords };
249252
253 /**
254 * A need as the terminal's forge strip prints it: a broken branch's card (its sentence names the
255 * branches) says where the terminal deletes them, the repository's branch list (`b`), as the page
256 * links each to its row (#12612).
257 */
258 export function needTermLine(n: ForgeNeed): string {
259 if (n.repo === undefined || n.links === undefined || n.links.length === 0) return n.line;
260 return `${n.line} In the terminal: open ${n.repo}, press b.`;
261 }
262
250263 /** A cause as one line: its sentence and when it began (a stuck run's says so already). */
251264 export function needLine(d: Degraded, now: number = Date.now()): string {
252265 return d.cause.startsWith("stuck:")
src/kernel/vitals.ts +9 −2
@@ -109,6 +109,12 @@ export interface Degraded {
109109 readonly sentence: string;
110110 readonly since: string;
111111 readonly href: string;
112 /**
113 * The repository the card is about, and a link each for what in it to act on (a broken
114 * branch's delete).
115 */
116 readonly repo?: string;
117 readonly links?: readonly { readonly label: string; readonly href: string }[];
112118 }
113119
114120 /** How many finished checks the median is taken over. */
@@ -419,6 +425,7 @@ export function vitals(input: VitalsInput): Vitals {
419425 sentence: string,
420426 evidence: string | undefined,
421427 href: string,
428 about?: { readonly repo: string; readonly links: NonNullable<Degraded["links"]> },
422429 ) => {
423430 let since = firstSeen.get(cause);
424431 if (since === undefined || (evidence !== undefined && evidence < since)) {
@@ -427,7 +434,7 @@ export function vitals(input: VitalsInput): Vitals {
427434 }
428435 needs.push(sentence);
429436 (kind === "broken" ? broken : todo).push(sentence);
430 degraded.push({ cause, sentence, since, href });
437 degraded.push({ cause, sentence, since, href, ...(about === undefined ? {} : { repo: about.repo, links: about.links }) });
431438 };
432439
433440 // Free memory under the floor the forge keeps for itself: what it serves with is gone.
@@ -647,7 +654,7 @@ export function vitals(input: VitalsInput): Vitals {
647654 if (failing !== undefined) need("todo", "snapshot-failed", failing.sentence, failing.since, "/settings/backups");
648655 // What the snapshot that landed could not hold is one card a repository until one holds it.
649656 for (const left of leftOutNeeds(lastSnapshotOutcome(input.dataDir)))
650 need("todo", left.cause, left.sentence, left.since, left.href);
657 need("todo", left.cause, left.sentence, left.since, left.href, left.links === undefined ? undefined : { repo: left.repo, links: left.links });
651658
652659 // The bucket itself, read by this process: late, unreadable, a failed drill, or a check that stopped is one card.
653660 if (isWatched(input.dataDir)) {
src/snapshot/outcome.ts +33 −4
@@ -121,6 +121,33 @@ export function snapshotNeed(
121121 };
122122 }
123123
124 /**
125 * One thing a snapshot left out; a broken branch's card carries a link a branch to where it is
126 * deleted.
127 */
128 export interface LeftOut {
129 readonly cause: string;
130 readonly repo: string;
131 readonly sentence: string;
132 readonly since: string;
133 /** Where the card goes: the branches page for broken branches, the repository otherwise. */
134 readonly href: string;
135 /**
136 * Each broken branch, named, to the branches page where its confirmed delete is. Plain text:
137 * the page escapes it.
138 */
139 readonly links?: readonly { readonly label: string; readonly href: string }[];
140 }
141
142 /** What settles a broken branch, and who may: nothing is deleted for them. */
143 export const SETTLE =
144 "Re-push each from a clone that still has its commits, or delete it on the branches page; the repository's owner or a writer can.";
145
146 /** The branches page of `owner/name`, each segment encoded for the URL. */
147 export function branchesHref(repo: string): string {
148 return `/${repo.split("/").map(encodeURIComponent).join("/")}/branches`;
149 }
150
124151 /** Branch names shown in one line before "and N more". */
125152 const NAMED = 5;
126153
@@ -130,19 +157,21 @@ const NAMED = 5;
130157 * stands until a snapshot lands without it. `href` is where a person clears it: a broken branch
131158 * is deleted on the repository's Branches page (docs/features/backup-refs.md).
132159 */
133 export function leftOutNeeds(s: SnapshotOutcome | undefined): { cause: string; repo: string; sentence: string; since: string; href: string }[] {
160 export function leftOutNeeds(s: SnapshotOutcome | undefined): LeftOut[] {
134161 if (s?.landedAt === undefined) return [];
135 const out: { cause: string; repo: string; sentence: string; since: string; href: string }[] = [];
162 const out: LeftOut[] = [];
136163 for (const b of s.brokenRefs ?? []) {
137164 const names = b.refs.map((r) => r.replace(/^refs\/heads\//, ""));
138165 const shown = names.slice(0, NAMED).join(", ");
139166 const more = names.length > NAMED ? `, and ${names.length - NAMED} more` : "";
167 const href = branchesHref(b.repo);
140168 out.push({
141169 cause: `backup-refs:${b.repo}`,
142170 repo: b.repo,
143 sentence: `${names.length} ${names.length === 1 ? "branch" : "branches"} of ${b.repo} cannot be backed up: their commits are missing (${shown}${more}). The rest of the repository is in the snapshot. Delete ${names.length === 1 ? "it" : "them"} on its Branches page.`,
171 sentence: `${names.length} ${names.length === 1 ? "branch" : "branches"} of ${b.repo} cannot be backed up: their commits are missing (${shown}${more}). The rest of the repository is in the snapshot. ${SETTLE}`,
144172 since: s.landedAt,
145 href: `/${b.repo}/branches`,
173 href,
174 links: names.map((label) => ({ label, href: `${href}#branch-${encodeURIComponent(label)}` })),
146175 });
147176 }
148177 for (const a of s.absent ?? [])
src/tui/screens/dashboard.ts +2 −2
@@ -19,7 +19,7 @@ import { exploreCount, exploreFiltered, exploreLine, isExploreLine, exploreNote,
1919 import { protectionNotice } from "../../kernel/protection.ts";
2020 import { holdWords, plannerHold } from "../../crew/autonomy.ts";
2121 import { governorLine, governorSeen } from "../../crew/governed.ts";
22 import { forgeFlakes, forgeLane, forgeNeeds } from "../../actions/health.ts";
22 import { forgeFlakes, forgeLane, forgeNeedList, needTermLine } from "../../actions/health.ts";
2323 import { ownerWaits, waitLine, withMore } from "../../actions/owner_waits.ts";
2424 import { forgeHealth } from "../../kernel/guard.ts";
2525 import { coveredByVerdict, forgeVerdict, verdictLine } from "../../kernel/guard_verdict.ts";
@@ -473,7 +473,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
473473 .filter((a) => a.fired)
474474 .map((a) => a.says)
475475 : [alarmStuck(f.db, now, { publicOnly: true })].filter((a) => a.fired).map((a) => a.says);
476 forge = forgeNeeds(f.app, f.user);
476 forge = forgeNeedList(f.app, f.user)?.map(needTermLine);
477477 if (forge !== undefined) {
478478 const fh = forgeHealth();
479479 const verdict = forgeVerdict(fh, Date.now());
src/tui/screens/deleterepo.ts +3 −2
@@ -42,7 +42,8 @@ export function deleteRepoCommands(f: Session, ctx: Ctx, repo: Repo | undefined)
4242 if (typed !== full) return `Type ${full} to confirm.`;
4343 // The prompt pops itself once this returns; the repository's
4444 // own screens unwind after the delete, never to read it again.
45 return (async () => {
45 // Tracked, so the app counts as busy until the unwinding is done.

Non-blocking: this ctx.track change fixes a flaky delete test and has nothing to do with the backup card. Prefer its own small pull next time.

46 return ctx.track((async () => {
4647 const done = await deleteRepo(f.app, f.user, repo);
4748 if (!done.ok) {
4849 ctx.toast(done.error === "not_found" ? "no such repository" : "could not delete the repository", "danger");
@@ -50,7 +51,7 @@ export function deleteRepoCommands(f: Session, ctx: Ctx, repo: Repo | undefined)
5051 }
5152 ctx.toast(`deleted ${full}`, "success");
5253 ctx.leaveRepo(repo.id);
53 })();
54 })());
5455 },
5556 }),
5657 ),
src/web/pages/board.ts +7 −1
@@ -30,6 +30,7 @@ import { ASKS_WINDOW_DAYS, askMeasureWeek, asksMeasureEmpty, asksMeasureParts }
3030 import { declinedWaits, reviewWaits } from "../../actions/owner_waits.ts";
3131 import { tokenReturns } from "../../core/returns.ts";
3232 import { forgeVitals, needLine } from "../../actions/health.ts";
33 import { needLinks } from "../need_links.ts";
3334 import { returnsRepos } from "../../actions/returns.ts";
3435 import {
3536 deciderCounts,
@@ -453,7 +454,12 @@ function forgeNotes(ctx: Ctx): { notes: Note[]; ok: boolean; placement: Html | n
453454 ...(ok
454455 ? []
455456 : v.degraded.map((d) =>
456 need(`degraded:${d.cause}`, html`<a data-need href="${d.href}">${dot("attn")} ${needLine(d)}</a>`),
457 need(
458 `degraded:${d.cause}`,
459 d.links === undefined
460 ? html`<a data-need href="${d.href}">${dot("attn")} ${needLine(d)}</a>`
461 : html`<span data-need>${dot("attn")} ${needLine(d)}${needLinks(d)}</span>`,
462 ),
457463 )),
458464 ...(lane === null ? [] : [{ key: "lane", need: false, line: html`<span>Lane: ${lane}</span>` }]),
459465 ...(flaky === null ? [] : [{ key: "flakes", need: false, line: html`<span data-flakes>Flaky this week: ${flaky}</span>` }]),
src/web/pages/branches.ts +2 −1
@@ -186,7 +186,8 @@ function branchRow(
186186 const base = scope.base;
187187 const encoded = encodeURIComponent(row.name);
188188 const canWrite = scope.caps.write && repo !== undefined;
189 return html`<li>
189 // The id a backup card's link lands on (#12612): `branchesHref` + `#branch-` + the encoded name.
190 return html`<li id="branch-${row.name}">
190191 <div class="row branch-row" data-nav tabindex="-1">
191192 <span class="row-lead">${icon("branch")}</span>
192193 <span class="row-main">
src/web/studio/asks_page.ts +2 −1
@@ -30,6 +30,7 @@ import { muteRepo, removeMutes } from "../../core/interactions.ts";
3030 import { applyAskFilter, isAskFilterDo, type AskFilterChange } from "../../actions/ask_filter.ts";
3131 import { askFiltersOf, hasAskFilters, hiddenLine, HIDE_APP_DAY_WORDS, HIDE_KIND_WORDS, isAskKind, SHOW_ALL_WORDS } from "../../core/ask_filters.ts";
3232 import type { ForgeNeed } from "../../actions/health.ts";
33 import { needLinks } from "../need_links.ts";
3334 import type { Ctx } from "../../http/context.ts";
3435 import type { User } from "../../core/users.ts";
3536 import { onYouAnswer, onYouRegion } from "./home.ts";
@@ -410,7 +411,7 @@ function rowCard(ctx: Ctx, r: AskRow<Decision>, picked: ReadonlySet<string>): Ht
410411 export const forgeCard = (d: ForgeNeed): Html =>
411412 html`<section class="stack">
412413 <h2>The forge</h2>
413 <p role="alert"><span class="dot" data-tone="danger" aria-hidden="true"></span> <a href="${d.href}">${d.line}</a></p>
414 <p role="alert"><span class="dot" data-tone="danger" aria-hidden="true"></span> ${d.links === undefined ? html`<a href="${d.href}">${d.line}</a>` : html`${d.line}${needLinks(d)}`}</p>
414415 <div class="bar">${d.cause.startsWith("probe:") ? btn("Remove", { href: d.href, size: "sm", variant: "primary" }) : null}${btn("Health", { href: "/api/v1/health", size: "sm" })}</div>
415416 </section>`;
416417
test/backup-card-pages.test.ts added +139
@@ -0,0 +1,139 @@
1 /**
2 * A broken branch's backup card on both doors (#12612): the board and `/asks`, read by a site
3 * admin who neither owns nor writes the repository, link each branch to its row on the branches
4 * page, that row carries the id the link lands on, the sentence says who may act once, and the
5 * terminal's forge strip says where its own delete is. A site admin writes every repository
6 * (`canWrite`), so the admin who reads the card is never barred from its delete: no line says
7 * "not you", and the test pins the premise so a change to it fails here first.
8 */
9
10 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
11 import { mkdtemp, rm } from "node:fs/promises";
12 import { tmpdir } from "node:os";
13 import { join } from "node:path";
14 import { createApp, type App } from "../src/app.ts";
15 import { forgeNeedList, needTermLine } from "../src/actions/health.ts";
16 import { deleteBranch } from "../src/actions/branches.ts";
17 import { getRepo } from "../src/core/repos.ts";
18 import { createForgeApp } from "../src/tui/forge.ts";
19 import { dashboardScreen } from "../src/tui/screens/dashboard.ts";
20 import { headlessTerminal } from "../src/tui/term/terminal.ts";
21 import { settleApp } from "./helpers/tui.ts";
22 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
23 import { createSession } from "../src/core/sessions.ts";
24 import { createUser, getUserByName } from "../src/core/users.ts";
25 import { serve, type Servers } from "../src/http/server.ts";
26 import { recordSnapshotOutcome, SETTLE } from "../src/snapshot/outcome.ts";
27 import { html } from "../src/web/html.ts";
28 import { adminCookie } from "./helpers/admin.ts";
29 import { quietLogs } from "./helpers/globals.ts";
30 import { promote } from "./helpers/members.ts";
31
32 quietLogs();
33
34 describe("a broken branch's card, read by a site admin who is not a writer", () => {
35 let dataDir = "";
36 let app: App;
37 let servers: Servers;
38 let admin = "";
39 let owner = "";
40
41 const get = async (cookie: string, path: string): Promise<string> => {
42 const response = await fetch(`${servers.url}${path}`, { headers: { cookie }, redirect: "manual" });
43 expect(response.status).toBe(200);
44 return (await response.text()).replace(/\s+/g, " ");
45 };
46
47 beforeAll(async () => {
48 dataDir = await mkdtemp(join(tmpdir(), "forge-backup-card-"));
49 app = createApp({ dataDir, port: 0, disk: () => ({ freeBytes: 95, totalBytes: 100 }) });
50 servers = await serve(app);
51 admin = `${await adminCookie(app, { username: "keeper", email: "[email protected]", password: "a-long-keeper-passphrase" })}; forge_mode=studio`;
52 const made = await createUser(app.db, {
53 origin: "seed",
54 trusted: true,
55 username: "alice",
56 email: "[email protected]",
57 password: "a-long-alice-passphrase",
58 });
59 if (!made.ok) throw new Error(made.error);
60 const alice = made.value;
61 promote(app.db, alice);
62 owner = `forge_session=${createSession(app.db, alice.id).token}`;
63 const repo = await createRepo(app, alice, { name: "notes", visibility: "public" });
64 if (!repo.ok) throw new Error(String(repo.error));
65 for (const branch of ["main", "lost"]) {
66 const c = await commitToBranch(app, alice, repo.value, {
67 branch,
68 message: branch,
69 files: [{ path: "README.md", content: `# ${branch}\n` }],
70 });
71 if (!c.ok) throw new Error(JSON.stringify(c.error));
72 }
73 recordSnapshotOutcome(dataDir, { landed: "y", brokenRefs: [{ repo: "alice/notes", refs: ["refs/heads/lost"] }] });
74 }, 30_000);
75
76 afterAll(async () => {
77 await servers.stop();
78 await rm(dataDir, { recursive: true, force: true });
79 });
80
81 const link = '<a href="/alice/notes/branches#branch-lost">lost</a>';
82
83 test("the board links the branch to its row and says who may act once", async () => {
84 const page = await get(admin, "/board");
85 expect(page).toContain(link);
86 expect(page.split(String(html`${SETTLE}`)).length - 1).toBe(1);
87 expect(page).not.toContain("ask one of them");
88 });
89
90 test("/asks links the branch to its row and says who may act once", async () => {
91 const page = await get(admin, "/asks");
92 expect(page).toContain(link);
93 expect(page.split(String(html`${SETTLE}`)).length - 1).toBe(1);
94 });
95
96 test("the branches page has the row the link lands on", async () => {
97 const page = await get(owner, "/alice/notes/branches");
98 expect(page).toContain('<li id="branch-lost">');
99 });
100
101 test("the admin who reads the card gets the branch's Delete on that row: it is theirs", async () => {
102 const page = await get(admin, "/alice/notes/branches");
103 expect(page).toContain('aria-label="Delete branch lost"');
104 expect(page).not.toContain("You cannot delete");
105 });
106
107 test("the strip renders on the dashboard with where its delete is", async () => {
108 const terminal = headlessTerminal(400, 60);
109 const { app: tui, session } = createForgeApp(
110 app,
111 { sshUsername: "keeper", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: getUserByName(app.db, "keeper")! },
112 { terminal, exitHooks: false },
113 );
114 tui.start();
115 tui.ctx.push(dashboardScreen(session, tui.ctx));
116 await settleApp(tui);
117 const text = tui.screen.toText().replace(/\s+/g, " ");
118 tui.stop?.();
119 expect(text).toContain("alice/notes cannot be backed up");
120 expect(text).toContain("In the terminal: open alice/notes, press b.");
121 });
122
123 test("the terminal's forge strip names where its delete is", () => {
124 // Gated as the page is: no strip for someone who is not a site admin.
125 expect(forgeNeedList(app, getUserByName(app.db, "alice"))).toBeUndefined();
126 const lines = (forgeNeedList(app, getUserByName(app.db, "keeper")) ?? []).map(needTermLine);
127 const card = lines.find((l) => l.includes("alice/notes cannot be backed up"));
128 expect(card).toContain(SETTLE);
129 expect(card).toEndWith("In the terminal: open alice/notes, press b.");
130 expect(lines.filter((l) => l.includes("In the terminal"))).toHaveLength(1);
131 });
132
133 // Last: it removes the branch the other tests read.
134 test("the delete the card links to accepts that admin", async () => {
135 const repo = getRepo(app.db, "alice", "notes")!;
136 const done = await deleteBranch(app, getUserByName(app.db, "keeper"), repo, "lost");
137 expect(done.ok).toBe(true);
138 });
139 });
test/snapshot-repositories.test.ts +53 −11
@@ -51,7 +51,8 @@ import {
5151 SEAL_SETTING,
5252 } from "../src/snapshot/destination.ts";
5353 import { isOffBox } from "../src/snapshot/off_box.ts";
54 import { lastSnapshotOutcome, leftOutNeeds } from "../src/snapshot/outcome.ts";
54 import { branchesHref, lastSnapshotOutcome, leftOutNeeds, recordSnapshotOutcome, SETTLE } from "../src/snapshot/outcome.ts";
55 import { needLinks } from "../src/web/need_links.ts";
5556 import { restoreSnapshot } from "../src/snapshot/restore.ts";
5657 import { startSnapshots } from "../src/snapshot/service.ts";
5758 import {
@@ -244,7 +245,7 @@ describe("a repository with refs whose commits are missing", () => {
244245 ]);
245246 const lines = leftOutNeeds(kept);
246247 expect(lines.map((l) => l.sentence)).toEqual([
247 "2 branches of alice/notes cannot be backed up: their commits are missing (lost, torn). The rest of the repository is in the snapshot. Delete them on its Branches page.",
248 "2 branches of alice/notes cannot be backed up: their commits are missing (lost, torn). The rest of the repository is in the snapshot. Re-push each from a clone that still has its commits, or delete it on the branches page; the repository's owner or a writer can.",
248249 ]);
249250 const card = forgeVitals(app).degraded.filter((d) =>
250251 d.cause.startsWith("backup-refs:"),
@@ -275,21 +276,62 @@ describe("a repository with refs whose commits are missing", () => {
275276 ).toContain(
276277 "7 branches of a/b cannot be backed up: their commits are missing (b0, b1, b2, b3, b4, and 2 more)",
277278 );
278 // One branch is "it".
279 expect(
280 leftOutNeeds({
281 at: "t",
282 landed: "x",
283 landedAt: "2026-11-14T08:05:00Z",
284 brokenRefs: [{ repo: "a/b", refs: ["refs/heads/lost"] }],
285 })[0]!.sentence,
286 ).toEndWith("Delete it on its Branches page.");
279 // One branch is "1 branch", and it is settled the same way.
280 const one = leftOutNeeds({
281 at: "t",
282 landed: "x",
283 landedAt: "2026-11-14T08:05:00Z",
284 brokenRefs: [{ repo: "a/b", refs: ["refs/heads/lost"] }],
285 })[0]!.sentence;
286 expect(one).toStartWith("1 branch of a/b cannot be backed up");
287 expect(one).toEndWith(SETTLE);
287288 expect(
288289 leftOutNeeds({ at: "t", landed: "x", landedAt: "2026-11-14T08:05:00Z" }),
289290 ).toEqual([]);
290291 });
291292 });
292293
294 describe("a broken branch's card links each branch to its delete (#12612)", () => {
295 const out = {
296 at: "t",
297 landed: "x",
298 landedAt: "2026-11-14T08:05:00Z",
299 brokenRefs: [{ repo: "alice/notes", refs: ["refs/heads/a<b", "refs/heads/x&y\"z"] }],
300 };
301
302 test("two broken refs give two links to the branches page, each name encoded in the URL", () => {
303 const [card] = leftOutNeeds(out);
304 expect(card!.href).toBe("/alice/notes/branches");
305 expect(card!.links).toEqual([
306 { label: "a<b", href: "/alice/notes/branches#branch-a%3Cb" },
307 { label: 'x&y"z', href: "/alice/notes/branches#branch-x%26y%22z" },
308 ]);
309 expect(card!.sentence).toContain("Re-push each from a clone that still has its commits, or delete it");
310 expect(card!.sentence).toContain("the repository's owner or a writer can");
311 expect(branchesHref("o w/n?m")).toBe("/o%20w/n%3Fm/branches");
312 });
313
314 test("rendered, the names are escaped, and who may act is not said a second time", () => {
315 const [card] = leftOutNeeds(out);
316 const can = String(needLinks(card!));
317 expect(can.match(/<a /g)?.length).toBe(2);
318 expect(can).toContain('<a href="/alice/notes/branches#branch-a%3Cb">a&lt;b</a>');
319 expect(can).toContain("x&amp;y&quot;z</a>");
320 expect(can).not.toContain("a<b");
321 expect(can).not.toContain("writer");
322 expect(needLinks({ links: [] })).toBeNull();
323 });
324
325 test("the vitals card carries the links and goes to the branches page; nothing is deleted", async () => {
326 recordSnapshotOutcome(app.config.dataDir, { landed: "y", brokenRefs: out.brokenRefs });
327 const [card] = forgeVitals(app).degraded.filter((d) => d.cause === "backup-refs:alice/notes");
328 expect(card!.href).toBe("/alice/notes/branches");
329 expect(card!.repo).toBe("alice/notes");
330 expect(card!.links?.map((l) => l.label)).toEqual(["a<b", 'x&y"z']);
331 recordSnapshotOutcome(app.config.dataDir, { landed: "z" });
332 });
333 });
334
293335 describe("a repository that cannot be bundled at all", () => {
294336 test("a bundle that runs out of time is not dropped silently: the manifest names it with the reason, and verify and the admin's line say so", async () => {
295337 const store = dirStore(fresh("store"));

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs