Skip to content
Myr

transcript.ts

This file

Path

apps/web/src/features/landing/transcript.ts

95 lines · 3.0 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

line 1why, one step back
1/**

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 2why, one step back
2 * Every `remote:` line comes from the one renderer, so it cannot drift from

Merge build/comments-web-features into mainoscabrielbefore adoption74bfc72

line 3why, one step back
3 * what the gateway sends; git's own lines around them are what

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 4–5why, one step back
4 * `apps/platform/test/core-loop.test.ts` asserts from real git, the landed
5 * commit's trailers among them.

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

line 6why, one step back
6 */

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 7–16why, one step back
7import { creditLine } from "@repo/git/trailers";
8import { Outcome } from "@repo/protocol/domain/outcome";9import {10 AskId,11 CommitSha,12 Handle,13 ProjectName,14 RepoPath,15 RequestId,16} from "@repo/protocol/ids";

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

line 17why, one step back
17import { OutOfScope } from "@repo/protocol/refusal";

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 18–19why, one step back
18import { explain, headline, receiptLine } from "@repo/protocol/render";
19import { Result } from "effect";

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

line 20why, one step back
20

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 21why, one step back
21const ASK = AskId.make("parse-iso");

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

line 22why, one step back
22

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 23–24why, one step back
23const FORK = `datekit--${ASK}--alice.git`;
24

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

lines 25–28why, one step back
25const refusals = [
26 new OutOfScope({ paths: [RepoPath.make("README.md")] }),27] as const;28

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 29why, one step back
29/** A command typed after `$`, a line the platform sent through git, or one git printed itself. */

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

line 30why, one step back
30export interface TranscriptLine {

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 31why, one step back
31 readonly kind: "command" | "remote" | "printed";

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

lines 32–34why, one step back
32 readonly text: string;
33}34

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 35–49why, one step back
35export interface Transcript {
36 readonly lines: readonly TranscriptLine[];37 /** The refusal's tag, drawn in the refused colour wherever it is printed. */38 readonly tag?: string;39}4041const command = (text: string): TranscriptLine => ({ kind: "command", text });4243const remote = (text: string): TranscriptLine => ({ kind: "remote", text });4445const printed = (text: string): TranscriptLine => ({ kind: "printed", text });4647/** A push the gate refused at its shape stage, as git prints it. */48export const refusedPush = (platformUrl: string): Transcript => {49 const fork = `${platformUrl.replace(/\/+$/u, "")}/${FORK}`;

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

lines 50–53why, one step back
50 const tag = headline(refusals);
5152 return {53 lines: [

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 54–58why, one step back
54 command("git push"),
55 ...explain(refusals).map(remote),56 printed(`To ${fork}`),57 printed(` ! [remote rejected] HEAD -> main (${tag})`),58 printed(`error: failed to push some refs to '${fork}'`),

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

line 59why, one step back
59 ],

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 60why, one step back
60 tag,

Merge build/1311-landing into mainoscabrielbefore adoption18b5418

lines 61–62why, one step back
61 };
62};

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 63–95why, one step back
63
64/**65 * Asks for the two credit trailers alone, so git prints exactly the two lines66 * drawn under it; a landing's other trailers (`Ask`, `Verdict`, `Request-Id`)67 * stay out of its output.68 */69export const LANDED_CREDITS =70 "git fetch && git log -1 --format='%(trailers:key=Asked-by,key=Signed-off-by)' origin/main";7172const HEAD = CommitSha.make("1a2b3c4d5e6f708192a3b4c5d6e7f80912a3b4c5");7374/** A push the gate took, then the landing commit's credit once it landed. */75export const landedPush = (): Transcript => ({76 lines: [77 command("git push"),78 remote(79 Result.getOrElse(80 receiptLine({81 ask: ASK,82 base: CommitSha.make("0".repeat(40)),83 head: HEAD,84 outcome: Outcome.cases.Checking.make({ stage: "merge" }),85 project: ProjectName.make("oscabriel/datekit"),86 requestId: RequestId.make(`push-${HEAD}`),87 }),88 () => ""89 )90 ),91 command(LANDED_CREDITS),92 printed(`Asked-by: ${creditLine(Handle.make("dora"))}`),93 printed(`Signed-off-by: ${creditLine(Handle.make("alice"))}`),94 ],95});