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

The remaining copies of the origin, app and report refusals import src/actions/origin_app_words.ts #16930

Merged opened this

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

Merged

mason/forge:mason/5692-the-remaining-copies-of-the-origin-app-a → main 0 commits fork

  • Merged. mason/5692-the-remaining-copies-of-the-origin-app-a was merged into main as ff172bb.

Review

Sign in to review this change.
9 files changed +39 −16
src/actions/migrate.ts +2 −1
@@ -35,6 +35,7 @@
3535 * checksums, on both sides (`apps/dump_import.ts`).
3636 */
3737
38 import { ORIGIN_UNREACHABLE } from "./origin_app_words.ts";
3839 import { NOT_A_MEMBER } from "../core/roles.ts";
3940 import { requireVerified } from "./verify.ts";
4041 import type { App } from "../app.ts";
@@ -757,7 +758,7 @@ async function afterWords(
757758 done.error.error === "unauthorized" ||
758759 done.error.error === "not_found"
759760 ? `. ${source.label} was not archived: the connected account lacks admin rights there. Archive it on the origin yourself`
760 : `. ${source.label} was not archived: the origin could not be reached`;
761 : `. ${source.label} was not archived: ${ORIGIN_UNREACHABLE}`;
761762 }
762763 const tips: Record<string, string> = {};
763764 for (const [ref, oid] of refs) if (ref.startsWith("refs/heads/")) tips[ref] = oid;
src/contract/openapi/routes/getApiV1UserOriginsIdRepos.ts +2 −1
@@ -1,3 +1,4 @@
1 import { ORIGIN_UNREACHABLE } from "../../../actions/origin_app_words.ts";
12 import type { Route } from "../shared.ts";
23
34 const U = "no valid credentials were sent";
@@ -17,7 +18,7 @@ export const route: Route = {
1718 forbidden: F,
1819 not_found: NF,
1920 invalid_group: "422, group is yours, shared or public",
20 origin_unreachable: "502, the origin could not be reached and nothing is cached",
21 origin_unreachable: `502, ${ORIGIN_UNREACHABLE} and nothing is cached`,
2122 },
2223 refuses: [401, 404],
2324 };
src/contract/openapi/routes/postApiV1ReposOwnerNameMakeItYours.ts +2 −1
@@ -1,3 +1,4 @@
1 import { APP_ALREADY_YOURS } from "../../../actions/origin_app_words.ts";
12 import { PROVE_FIRST } from "../../../actions/verify_words.ts";
23 import { REPO, type Route } from "../shared.ts";
34 import { VISIBILITY_WORDS } from "../../../core/arg_words.ts";
@@ -14,7 +15,7 @@ export const route: Route = {
1415 body: { dryRun: "boolean", name: "string", visibility: "string" },
1516 refusals: {
1617 invalid: `422: ${VISIBILITY_WORDS}`,
17 own: "409: this app is already yours",
18 own: `409: ${APP_ALREADY_YOURS}`,
1819 unverified: `403: ${PROVE_FIRST}`,
1920 limit: "429: at most so many copies a day; { resetsAt }",
2021 repository_limit: "403: at the repository limit",
src/contract/openapi/routes/postApiV1UserOriginsIdBrowseOwnerNameContribute.ts +2 −1
@@ -1,3 +1,4 @@
1 import { ORIGIN_UNREACHABLE } from "../../../actions/origin_app_words.ts";
12 import { PROVE_FIRST } from "../../../actions/verify_words.ts";
23 import { BROWSE, type Route } from "../shared.ts";
34
@@ -15,7 +16,7 @@ export const route: Route = {
1516 refusals: {
1617 not_found: "404: no such origin of yours, or no such repository there",
1718 unverified: `403: ${PROVE_FIRST}`,
18 origin_unreachable: "422: the origin could not be reached",
19 origin_unreachable: `422: ${ORIGIN_UNREACHABLE}`,
1920 invalid_branch: "422: that branch is not one this forge can use",
2021 unknown_base: "422: that base branch is not one this forge can use",
2122 fork_timeout: "504: the origin took the fork and it has not appeared yet; try again shortly",
src/contract/openapi/routes/postApiV1UserOriginsIdFork.ts +2 −1
@@ -1,3 +1,4 @@
1 import { ORIGIN_UNREACHABLE } from "../../../actions/origin_app_words.ts";
12 import type { Route } from "../shared.ts";
23
34 export const route: Route = {
@@ -11,7 +12,7 @@ export const route: Route = {
1112 status: 202,
1213 refusals: {
1314 not_found: "404: no such origin of yours",
14 origin_unreachable: "422: the origin could not be reached",
15 origin_unreachable: `422: ${ORIGIN_UNREACHABLE}`,
1516 fork_timeout: "504: the origin took the fork and it has not appeared yet; try again shortly",
1617 mirror_failed: "502: a local copy of the fork could not be made",
1718 },
src/contract/openapi/shared.ts +3 −2
@@ -4,6 +4,7 @@
44 * uses lives in that route's file.
55 */
66
7 import { ORIGIN_UNREACHABLE } from "../../actions/origin_app_words.ts";
78 import { LIST_LIMIT_MAX } from "../../core/issues.ts";
89 import {
910 LIST_READER_FIELDS,
@@ -104,7 +105,7 @@ export const LABEL_REFUSALS = {
104105 forbidden: "the caller cannot write to the repository",
105106 mirrored: "the repository mirrors an origin; do it there",
106107 origin_owner_only: "only the person who connected the origin can write through it",
107 origin_unreachable: "the origin could not be reached (502)",
108 origin_unreachable: `${ORIGIN_UNREACHABLE} (502)`,
108109 origin_refused: "the origin refused the change (409)",
109110 };
110111
@@ -119,7 +120,7 @@ export const BROWSE_REFUSALS = {
119120 not_found: "404: no such origin of yours, or the origin has no such repository, issue or pull",
120121 rate_limited: "429: the origin is rate-limiting this forge",
121122 origin_unauthorized: "502: the origin refused this forge's credential; reconnect it",
122 origin_unreachable: "502: the origin could not be reached",
123 origin_unreachable: `502: ${ORIGIN_UNREACHABLE}`,
123124 };
124125
125126 /** The refusals every live browse of an origin's code can answer (`sourceFailure` in `http/api/user.ts`); the connecting user only. */
src/origins/mirror.ts +2 −1
@@ -11,6 +11,7 @@
1111 * leave a mirror you can retry, not a half-created nothing.
1212 */
1313
14 import { ORIGIN_UNREACHABLE } from "../actions/origin_app_words.ts";
1415 import { lacks, NOT_A_MEMBER } from "../core/roles.ts";
1516 import type { App } from "../app.ts";
1617 import {
@@ -339,7 +340,7 @@ export function mirrorMessage(error: MirrorError): string {
339340 case "dir_in_the_way":
340341 return "a folder on disk already holds that name, with no repository behind it";
341342 case "unreachable":
342 return "the origin could not be reached";
343 return ORIGIN_UNREACHABLE;
343344 case "repository_limit":
344345 return "this account is at the forge's repositories limit";
345346 case "storage_limit":
src/tui/screens/common.ts +2 −1
@@ -7,6 +7,7 @@
77 * of them. Nothing here knows about repos or issues — that is the point.
88 */
99
10 import { ORIGIN_UNREACHABLE } from "../../actions/origin_app_words.ts";
1011 import { DELETING_SAYS } from "../../core/repo_deleting.ts";
1112 import { CHECK_STALE_REFUSAL } from "../../checks/stale.ts";
1213 import { DRAFT_REFUSAL } from "../../core/pulls.ts";
@@ -1053,7 +1054,7 @@ const MESSAGES: Record<string, string> = {
10531054 origin_read_only: "this account was connected read-only; nothing is written through it",
10541055 origin_paused: "this connection is not verified yet; writes are paused",
10551056 origin_protected: "the operator protects this repository at its origin: nothing is pushed to it from here; propose the change from your fork",
1056 origin_unreachable: "the origin could not be reached; nothing changed",
1057 origin_unreachable: `${ORIGIN_UNREACHABLE}; nothing was changed`,
10571058 already_connected: ORIGIN_ALREADY_CONNECTED,
10581059 already_mirrored: "that repository is already mirrored here",
10591060 unknown_host: "that does not look like a forge",
test/origin-app-words.test.ts +22 −7
@@ -38,7 +38,20 @@ const SENTENCES = {
3838 REPORT_ALREADY_DECIDED: "this report was already decided",
3939 } as const;
4040
41 const DOORS = ["src/http/api.ts", "src/http/mcp.ts"] as const;
41 // Each door and the sentences it says; the API and the MCP say all three.
42 const ALL = Object.keys(SENTENCES) as (keyof typeof SENTENCES)[];
43 const DOORS: Record<string, readonly (keyof typeof SENTENCES)[]> = {
44 "src/http/api.ts": ALL,
45 "src/http/mcp.ts": ALL,
46 "src/origins/mirror.ts": ["ORIGIN_UNREACHABLE"],
47 "src/actions/migrate.ts": ["ORIGIN_UNREACHABLE"],
48 "src/tui/screens/common.ts": ["ORIGIN_UNREACHABLE"],
49 "src/contract/openapi/shared.ts": ["ORIGIN_UNREACHABLE"],
50 "src/contract/openapi/routes/postApiV1UserOriginsIdFork.ts": ["ORIGIN_UNREACHABLE"],
51 "src/contract/openapi/routes/postApiV1UserOriginsIdBrowseOwnerNameContribute.ts": ["ORIGIN_UNREACHABLE"],
52 "src/contract/openapi/routes/getApiV1UserOriginsIdRepos.ts": ["ORIGIN_UNREACHABLE"],
53 "src/contract/openapi/routes/postApiV1ReposOwnerNameMakeItYours.ts": ["APP_ALREADY_YOURS"],
54 };
4255
4356 describe("origin, app and report refusals live in one module", () => {
4457 test("the module says each sentence, word for word", () => {
@@ -49,14 +62,16 @@ describe("origin, app and report refusals live in one module", () => {
4962 }).toEqual(SENTENCES);
5063 });
5164
52 for (const door of DOORS) {
65 for (const [door, names] of Object.entries(DOORS)) {
5366 test(`${door} imports the sentences and types none of them out`, () => {
5467 const text = read(door);
55 expect(importsFrom(text, "actions/origin_app_words.ts")).toBe(true);
56 for (const [name, sentence] of Object.entries(SENTENCES)) {
57 expect(text).toContain(name);
58 expect(text).not.toContain(sentence);
59 }
68 // A module inside src/actions/ imports its sibling as "./origin_app_words.ts".
69 const imported = door.startsWith("src/actions/")
70 ? text.includes('from "./origin_app_words.ts"')
71 : importsFrom(text, "actions/origin_app_words.ts");
72 expect(imported).toBe(true);
73 for (const name of names) expect(text).toContain(name);
74 for (const sentence of Object.values(SENTENCES)) expect(text).not.toContain(sentence);
6075 });
6176 }
6277 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs