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

A mirror's "do it there" sentence lives in one module, read by issue teams and the thread page #5638

Merged opened this

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

Merged

mason/forge:mason/5591-a-mirror-s-do-it-there-sentence-lives-in → main 1 commit fork

  • Merged. mason/5591-a-mirror-s-do-it-there-sentence-lives-in was merged into main as 7834bf8.

Review

Sign in to review this change.
4 files changed +47 −4
src/actions/issue_teams.ts +2 −2
@@ -11,13 +11,13 @@ import type { User } from "../core/users.ts";
1111 import { err, type Result } from "../kernel/result.ts";
1212 import { isMirror } from "../origins/write-through.ts";
1313 import { requireWriter, type AccessError } from "./access.ts";
14 import { MIRRORED_DO_IT_THERE } from "./mirror_words.ts";
1415
1516 /** One sentence per refusal, said the same by the page, API, MCP tool and terminal. */
1617 export const ISSUE_TEAMS_SAY: Record<string, string> = {
1718 too_many: `An issue names at most ${TEAMS_MAX} teams.`,
1819 no_such_team: "No such team.",
19 mirrored:
20 "This repository mirrors an origin — do it there, and the next sync brings it back.",
20 mirrored: MIRRORED_DO_IT_THERE,
2121 unauthorized: "Sign in to name teams.",
2222 forbidden: "You need write access to name teams.",
2323 not_found: "No such issue.",
src/actions/mirror_words.ts added +8
@@ -0,0 +1,8 @@
1 /**
2 * What a mirror says when a local write belongs on its origin (#5591):
3 * one sentence, said the same by the issue teams action and the thread page.
4 */
5
6 /** A mirror's issues and pulls are the origin's: the change is made there. */
7 export const MIRRORED_DO_IT_THERE =
8 "This repository mirrors an origin — do it there, and the next sync brings it back.";
src/web/pages/thread.ts +2 −2
@@ -10,6 +10,7 @@
1010
1111 import { mayView } from "../../core/sealed.ts";
1212 import { ISSUE_TEAMS_SAY, nameTeams } from "../../actions/issue_teams.ts";
13 import { MIRRORED_DO_IT_THERE } from "../../actions/mirror_words.ts";
1314 import { teamsOfIssue, TEAMS_MAX } from "../../core/issue_teams.ts";
1415 import { listTeams } from "../../core/teams.ts";
1516 import { listCrew } from "../../actions/crew.ts";
@@ -81,8 +82,7 @@ import { interruptionsOn } from "../../crew/interrupted.ts";
8182 */
8283 export function originError(error: string): string | undefined {
8384 const words: Record<string, string> = {
84 mirrored:
85 "This repository mirrors an origin — do it there, and the next sync brings it back.",
85 mirrored: MIRRORED_DO_IT_THERE,
8686 origin_owner_only:
8787 "Only the person who connected this origin can write through it. Your comment would otherwise appear upstream under their name.",
8888 origin_refused: "The origin refused that. Nothing was changed here either.",
test/mirror-words.test.ts added +35
@@ -0,0 +1,35 @@
1 /**
2 * A mirror's "do it there" sentence is said from one module (#5591): the
3 * issue teams action and the thread page import it, and neither types a
4 * copy of it back.
5 */
6
7 import { describe, expect, test } from "bun:test";
8 import { readFileSync } from "node:fs";
9 import { join } from "node:path";
10 import * as words from "../src/actions/mirror_words.ts";
11
12 const READERS = ["src/actions/issue_teams.ts", "src/web/pages/thread.ts"];
13
14 describe("a mirror's words live in one module", () => {
15 const sentences = Object.entries(words);
16
17 test("each exported sentence is a non-empty string", () => {
18 expect(sentences.length).toBeGreaterThan(0);
19 for (const [, sentence] of sentences) {
20 expect(typeof sentence).toBe("string");
21 expect((sentence as string).trim()).not.toBe("");
22 }
23 });
24
25 for (const file of READERS) {
26 test(`${file} imports the sentences and types none of them`, () => {
27 const source = readFileSync(join(import.meta.dir, "..", file), "utf8");
28 expect(source).toContain("mirror_words.ts");
29 for (const [name, sentence] of sentences) {
30 expect(source).toContain(name);
31 expect(source).not.toContain(sentence as string);
32 }
33 });
34 }
35 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs