Public: anyone can read this; the crew can change it.
Test: dev-cell's git fixture runs with a built environment, not the host's #17608
Merged 15h 36m ago, live in production
dev-cell-git-env → main 0 commits 2 threads · 2 unresolved
59 files
changed +165
−61
- test/app-release-15497.test.ts
- test/both-doors-refusal.test.ts
- test/box-pass.test.ts
- test/comment-wrap.test.ts
- test/contract-audit-cache.test.ts
- test/crew-interrupted.test.ts
- test/deepsec-step.test.ts
- test/dev-cell.test.ts
- test/direction-refusal.test.ts
- test/dupes.test.ts
- test/error-fixes.test.ts
- test/flow-red-batches.test.ts
- test/forge-box-unit.test.ts
- test/fork-detach.test.ts
- test/gate-added-refusal.test.ts
- test/gate-base-list.test.ts
- test/gate-dependencies.test.ts
- test/gate-explain.test.ts
- test/gate-last-slot.test.ts
- test/gate-look-note.test.ts
- test/gate-readme-cap.test.ts
- test/gate-update-pull.test.ts
- test/git-spawn-failure.test.ts
- test/guest-contribute.test.ts
- test/helpers/build-standin-builder.ts
- test/helpers/stranger-builder.ts
- test/lands-once.test.ts
- test/log-tail-view.test.ts
- test/merge-queue-batch.test.ts
- test/merge-queue-check-retry.test.ts
- test/merge-queue-clash.test.ts
- test/merge-queue-gate-result.test.ts
- test/merge-queue-parallel.test.ts
- test/merge-queue-reason.test.ts
- test/merge-queue-restart.test.ts
- test/merge-queue-revert-alone.test.ts
- test/merge-queue-search.test.ts
- test/merge-queue-suspect.test.ts
- test/merge-queue.test.ts
- test/orphan-clones.test.ts
- test/path-listing.test.ts
- test/pin-refusal.test.ts
- test/queue-verdicts.test.ts
- test/red-on-main.test.ts
- test/release-subject.test.ts
- test/repo-delete-forks.test.ts
- test/revert-gate.test.ts
- test/scripts-fast.test.ts
- test/search-grep-stops.test.ts
- test/shards-run.test.ts
- test/spawn-argv.test.ts
- test/spawn-template-birth.test.ts
- test/tags-etag.test.ts
- test/template-scripts.test.ts
- test/test-budget-run.test.ts
- test/test-git-env.test.ts
- test/tests-with-change.test.ts
- test/try-it.test.ts
- test/tui-forks-take.test.ts
test/app-release-15497.test.ts +2 −1
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * `/api/v1/health` reads it back as `release`. A preview is never told one. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 10 | 11 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 11 | 12 | import { mkdtemp, rm } from "node:fs/promises"; |
| 12 | 13 | import { tmpdir } from "node:os"; |
| @@ -19,7 +20,7 @@ import { releaseOf, running } from "../src/kernel/version.ts"; | ||
| 19 | 20 | import { ownProbeHeaders } from "../src/kernel/probe.ts"; |
| 20 | 21 | |
| 21 | 22 | const git = (cwd: string, ...args: string[]): string => { |
| 22 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "[email protected]", "-c", "tag.gpgSign=false", "-c", "commit.gpgSign=false", ...args], { cwd }); | |
| 23 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "[email protected]", "-c", "tag.gpgSign=false", "-c", "commit.gpgSign=false", ...args], { env: gitClientEnv(), cwd }); | |
| 23 | 24 | if (r.exitCode !== 0) throw new Error(`git ${args.join(" ")}: ${r.stderr.toString()}`); |
| 24 | 25 | return r.stdout.toString().trim(); |
| 25 | 26 | }; |
test/both-doors-refusal.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { join } from "node:path"; |
| @@ -8,7 +9,7 @@ const root = mkdtempSync(join(tmpdir(), "both-doors-")); | ||
| 8 | 9 | afterAll(() => rmSync(root, { recursive: true, force: true })); |
| 9 | 10 | |
| 10 | 11 | const run = (cwd: string, ...args: string[]) => { |
| 11 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 12 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 12 | 13 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 13 | 14 | return r.stdout.toString().trim(); |
| 14 | 15 | }; |
test/box-pass.test.ts +2 −1
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | * whose boxes are all ticked, and an issue held for boxes gets the same pass |
| 5 | 5 | * once. A builder is still never sent to redo shipped work. |
| 6 | 6 | */ |
| 7 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 7 | 8 | import { seatAs } from "./helpers/seat.ts"; |
| 8 | 9 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 9 | 10 | import { mkdtemp, rm } from "node:fs/promises"; |
| @@ -261,7 +262,7 @@ describe("the reviewer's pass over the boxes", () => { | ||
| 261 | 262 | ["reflog", "expire", "--expire=now", "--all"], |
| 262 | 263 | ["gc", "--prune=now", "--quiet"], |
| 263 | 264 | ]) { |
| 264 | const ran = Bun.spawnSync(["git", ...args], { cwd: bare }); | |
| 265 | const ran = Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: bare }); | |
| 265 | 266 | if (ran.exitCode !== 0) throw new Error(ran.stderr.toString()); |
| 266 | 267 | } |
| 267 | 268 | const gone = Bun.spawnSync(["git", "cat-file", "-e", `${pull.headOid}^{commit}`], { cwd: bare }); |
test/comment-wrap.test.ts +2 −1
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @not-a-tree-scan: every file it reads is in a temp directory of its own. |
| 6 | 6 | */ |
| 7 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 7 | 8 | import { expect, test } from "bun:test"; |
| 8 | 9 | import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 9 | 10 | import { tmpdir } from "node:os"; |
| @@ -143,7 +144,7 @@ test("a pull is read, and fixed, only in the files it changes", () => { | ||
| 143 | 144 | const root = mkdtempSync(join(tmpdir(), "forge-wrap-git-")); |
| 144 | 145 | const saved = process.env.FORGE_CHECK_BASE; |
| 145 | 146 | const sh = (...a: string[]) => { |
| 146 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...a], { cwd: root }); | |
| 147 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...a], { env: gitClientEnv(), cwd: root }); | |
| 147 | 148 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 148 | 149 | return r.stdout.toString().trim(); |
| 149 | 150 | }; |
test/contract-audit-cache.test.ts +2 −1
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | * `audit` keeps a repository's policy by (repository, tip): a warm read is |
| 3 | 3 | * fast, and a push that changes forge.json is seen on the next read. |
| 4 | 4 | */ |
| 5 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 5 | 6 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 6 | 7 | import { existsSync, mkdtempSync, rmSync } from "node:fs"; |
| 7 | 8 | import { tmpdir } from "node:os"; |
| @@ -84,7 +85,7 @@ test("a packed ref takes the git path, agrees with git, and a push still invalid | ||
| 84 | 85 | const repo = () => getRepo(app.db, "alice", "packed")!; |
| 85 | 86 | const dir = repoDir(app.reposRoot, "alice", "packed"); |
| 86 | 87 | const git = (...args: string[]) => |
| 87 | Bun.spawnSync(["git", "-C", dir, ...args]).stdout.toString().trim(); | |
| 88 | Bun.spawnSync(["git", "-C", dir, ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 88 | 89 | |
| 89 | 90 | await write(contract("anon")); |
| 90 | 91 | git("pack-refs", "--all"); |
test/crew-interrupted.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 2 | 3 | import type { Database } from "bun:sqlite"; |
| 3 | 4 | import { listActive, type RunKind } from "../src/core/runs.ts"; |
| @@ -566,7 +567,7 @@ echo '{"type":"result","subtype":"success","is_error":false,"result":"Done.","to | ||
| 566 | 567 | const { repo, clone } = await keptClone("paddock"); |
| 567 | 568 | writeFileSync(join(clone, "LOST.md"), "unpushed\n"); |
| 568 | 569 | const git = (...args: string[]) => |
| 569 | Bun.spawnSync(["git", ...args], { cwd: clone }); | |
| 570 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: clone }); | |
| 570 | 571 | git("add", "LOST.md"); |
| 571 | 572 | git("-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "local"); |
| 572 | 573 | writeFileSync(join(clone, ".git", "index.lock"), ""); |
test/deepsec-step.test.ts +2 −1
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | * links its scope out of the checkout, an outside contributor's pull, or a host with no cell gets |
| 5 | 5 | * no run. |
| 6 | 6 | */ |
| 7 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 7 | 8 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 8 | 9 | import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; |
| 9 | 10 | import { tmpdir } from "node:os"; |
| @@ -21,7 +22,7 @@ let bare = ""; | ||
| 21 | 22 | let base = ""; |
| 22 | 23 | let head = ""; |
| 23 | 24 | const git = (cwd: string, ...args: string[]): string => { |
| 24 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd, stdout: "pipe", stderr: "pipe" }); | |
| 25 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd, stdout: "pipe", stderr: "pipe" }); | |
| 25 | 26 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 26 | 27 | return r.stdout.toString().trim(); |
| 27 | 28 | }; |
test/dev-cell.test.ts +4 −1
| @@ -17,11 +17,14 @@ import { serve, type Servers } from "../src/http/server.ts"; | ||
| 17 | 17 | import { err, ok } from "../src/kernel/result.ts"; |
| 18 | 18 | import { pollUntil } from "./helpers/poll.ts"; |
| 19 | 19 | import { quietLogs } from "./helpers/globals.ts"; |
| 20 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 20 | 21 | |
| 21 | 22 | quietLogs(); |
| 22 | 23 | |
| 24 | // A built environment, never the host's: a machine's own git configuration (fetch.prune on a | |
| 25 | // Mac) made the fixture's fetch fail there. | |
| 23 | 26 | const git = async (cwd: string, ...args: string[]): Promise<void> => { |
| 24 | const made = await runLocal(["-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 27 | const made = await runLocal(["-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd, env: gitClientEnv() }); | |
| 25 | 28 | if (!made.ok) throw new Error(`git ${args.join(" ")}: ${made.error.stderr}`); |
| 26 | 29 | }; |
| 27 | 30 |
test/direction-refusal.test.ts +3 −2
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { join } from "node:path"; |
| @@ -8,7 +9,7 @@ const root = mkdtempSync(join(tmpdir(), "direction-")); | ||
| 8 | 9 | afterAll(() => rmSync(root, { recursive: true, force: true })); |
| 9 | 10 | |
| 10 | 11 | const run = (cwd: string, ...args: string[]) => { |
| 11 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 12 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 12 | 13 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 13 | 14 | return r.stdout.toString().trim(); |
| 14 | 15 | }; |
| @@ -128,7 +129,7 @@ test("a failing git diff --numstat refuses the pull rather than skipping the red | ||
| 128 | 129 | run(dir, "commit", "-qm", "Add home"); |
| 129 | 130 | const git = (args: string[], cwd: string = dir) => { |
| 130 | 131 | if (args.includes("--numstat")) return { ok: false, out: "" }; |
| 131 | const r = Bun.spawnSync(["git", ...args], { cwd }); | |
| 132 | const r = Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd }); | |
| 132 | 133 | return { ok: r.exitCode === 0, out: r.stdout.toString().trim() }; |
| 133 | 134 | }; |
| 134 | 135 | const out = await withBase(base, () => directionRefusal(dir, git)); |
test/dupes.test.ts +2 −1
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | /** The duplication report (#14620): shapes, clusters, the tuned threshold, and the gate's note. */ |
| 2 | 2 | |
| 3 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 3 | 4 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 4 | 5 | import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 5 | 6 | import { tmpdir } from "node:os"; |
| @@ -83,7 +84,7 @@ test("the threshold is the one that best splits the forge's own labeled pairs", | ||
| 83 | 84 | |
| 84 | 85 | let dir: string; |
| 85 | 86 | const git = (...args: string[]) => { |
| 86 | const r = Bun.spawnSync(["git", ...args], { cwd: dir, stderr: "pipe" }); | |
| 87 | const r = Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: dir, stderr: "pipe" }); | |
| 87 | 88 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 88 | 89 | return r.stdout.toString().trim(); |
| 89 | 90 | }; |
test/error-fixes.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdtemp, rm } from "node:fs/promises"; |
| 3 | 4 | import { tmpdir } from "node:os"; |
| @@ -47,7 +48,7 @@ describe("errors resolve when the pull that fixes them is deployed (#16974)", () | ||
| 47 | 48 | return app.db.query<{ id: string }, [string]>("SELECT id FROM error_group WHERE fingerprint = ?1").get(`fp-${type}`)!.id; |
| 48 | 49 | }; |
| 49 | 50 | const commit = async (parent: string | undefined, msg: string): Promise<string> => { |
| 50 | const tree = (await runLocal(["hash-object", "-t", "tree", "-w", "--stdin"], { cwd: dir, stdin: "" })); | |
| 51 | const tree = (await runLocal(["hash-object", "-t", "tree", "-w", "--stdin"], { env: gitClientEnv(), cwd: dir, stdin: "" })); | |
| 51 | 52 | const args = ["commit-tree", tree.ok ? tree.value.trim() : "", "-m", msg, ...(parent ? ["-p", parent] : [])]; |
| 52 | 53 | const made = await runLocal(args, { cwd: dir, env: { GIT_AUTHOR_NAME: "t", GIT_AUTHOR_EMAIL: "[email protected]", GIT_COMMITTER_NAME: "t", GIT_COMMITTER_EMAIL: "[email protected]" } }); |
| 53 | 54 | if (!made.ok) throw new Error("commit-tree failed"); |
test/flow-red-batches.test.ts +2 −1
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | * batch's bisection is one batch, and a pull check none, is checked through |
| 5 | 5 | * the real queue with a stand-in gate that goes red on any `red-*` file. |
| 6 | 6 | */ |
| 7 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 7 | 8 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 8 | 9 | import { mkdtemp, rm } from "node:fs/promises"; |
| 9 | 10 | import { tmpdir } from "node:os"; |
| @@ -31,7 +32,7 @@ describe("the red-batch rate", () => { | ||
| 31 | 32 | let gates = 0; |
| 32 | 33 | |
| 33 | 34 | const git = (repo: Repo, ...args: string[]) => |
| 34 | Bun.spawnSync(["git", ...args], { cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 35 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 35 | 36 | .stdout.toString() |
| 36 | 37 | .trim(); |
| 37 | 38 |
test/forge-box-unit.test.ts +2 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | /** The box's systemd unit (`infra/forge-box/forge.service`) says what docs/EXTRACT.md step 3 says. */ |
| 2 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 2 | 3 | import { expect, test } from "bun:test"; |
| 3 | 4 | import { mkdtempSync, readFileSync, rmSync, statSync } from "node:fs"; |
| 4 | 5 | import { tmpdir } from "node:os"; |
| @@ -109,7 +110,7 @@ test("the unit's ports are defaults that forge.env may override, and the install | ||
| 109 | 110 | }); |
| 110 | 111 | |
| 111 | 112 | function git(cwd: string, ...args: string[]) { |
| 112 | const r = Bun.spawnSync(["git", ...args], { cwd, stderr: "pipe", stdout: "pipe" }); | |
| 113 | const r = Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd, stderr: "pipe", stdout: "pipe" }); | |
| 113 | 114 | return { code: r.exitCode, out: r.stdout.toString().trim(), err: r.stderr.toString() }; |
| 114 | 115 | } |
| 115 | 116 |
test/fork-detach.test.ts +2 −1
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | * and a repository admin detaches a fork from its parent — planned first, |
| 5 | 5 | * repacked off the request path, then the parent forgotten. |
| 6 | 6 | */ |
| 7 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 7 | 8 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 8 | 9 | import { mkdtemp, rm } from "node:fs/promises"; |
| 9 | 10 | import { tmpdir } from "node:os"; |
| @@ -36,7 +37,7 @@ const ok = <T>(r: { ok: true; value: T } | { ok: false; error: unknown }): T => | ||
| 36 | 37 | }; |
| 37 | 38 | |
| 38 | 39 | const git = async (cwd: string, ...args: string[]) => { |
| 39 | const p = Bun.spawn(["git", ...args], { cwd, stdout: "pipe", stderr: "pipe" }); | |
| 40 | const p = Bun.spawn(["git", ...args], { env: gitClientEnv(), cwd, stdout: "pipe", stderr: "pipe" }); | |
| 40 | 41 | const [out, code] = await Promise.all([new Response(p.stdout).text(), p.exited]); |
| 41 | 42 | return { out: out.trim(), code }; |
| 42 | 43 | }; |
test/gate-added-refusal.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterEach, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { tmpdir } from "node:os"; |
| @@ -14,7 +15,7 @@ afterEach(() => { | ||
| 14 | 15 | }); |
| 15 | 16 | |
| 16 | 17 | function sh(cwd: string, ...args: string[]): string { |
| 17 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { cwd }); | |
| 18 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), cwd }); | |
| 18 | 19 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 19 | 20 | return r.stdout.toString().trim(); |
| 20 | 21 | } |
test/gate-base-list.test.ts +2 −1
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | * is refused with the file named, even when it also deletes the refusal from its own gate, since |
| 4 | 4 | * the forge runs the base's copy (`src/checks/base_gate.ts`). A pull that only adds a file passes. |
| 5 | 5 | */ |
| 6 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 6 | 7 | import { afterEach, expect, test } from "bun:test"; |
| 7 | 8 | import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 8 | 9 | import { tmpdir } from "node:os"; |
| @@ -18,7 +19,7 @@ afterEach(() => { | ||
| 18 | 19 | }); |
| 19 | 20 | |
| 20 | 21 | function sh(cwd: string, ...args: string[]): string { |
| 21 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { cwd }); | |
| 22 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), cwd }); | |
| 22 | 23 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 23 | 24 | return r.stdout.toString().trim(); |
| 24 | 25 | } |
test/gate-dependencies.test.ts +2 −1
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | * The gate refuses a pull that adds a package with no line of why (#12315): |
| 3 | 3 | * judged against FORGE_CHECK_BASE in a real repository, devDependencies too. |
| 4 | 4 | */ |
| 5 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 5 | 6 | import { afterEach, expect, test } from "bun:test"; |
| 6 | 7 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 7 | 8 | import { tmpdir } from "node:os"; |
| @@ -18,7 +19,7 @@ afterEach(() => { | ||
| 18 | 19 | }); |
| 19 | 20 | |
| 20 | 21 | function sh(cwd: string, ...args: string[]): string { |
| 21 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { cwd }); | |
| 22 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), cwd }); | |
| 22 | 23 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 23 | 24 | return r.stdout.toString().trim(); |
| 24 | 25 | } |
test/gate-explain.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { join } from "node:path"; |
| @@ -9,7 +10,7 @@ const root = mkdtempSync(join(tmpdir(), "gate-explain-")); | ||
| 9 | 10 | afterAll(() => rmSync(root, { recursive: true, force: true })); |
| 10 | 11 | |
| 11 | 12 | const git = (cwd: string, ...args: string[]) => { |
| 12 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 13 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 13 | 14 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 14 | 15 | return r.stdout.toString().trim(); |
| 15 | 16 | }; |
test/gate-last-slot.test.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * once as it starts, and the tests wait on a run's state or a gate's own |
| 7 | 7 | * promise, never on a fixed delay. |
| 8 | 8 | */ |
| 9 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 9 | 10 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 10 | 11 | import { mkdtemp, rm } from "node:fs/promises"; |
| 11 | 12 | import { tmpdir } from "node:os"; |
| @@ -128,7 +129,7 @@ test("a pull's check does not take the last slot while a gate is forming", async | ||
| 128 | 129 | test("a gate that is running keeps the slot: the pull's check starts when it settles", async () => { |
| 129 | 130 | const dir = await mkdtemp(join(tmpdir(), "forge-gate-last-slot-git-")); |
| 130 | 131 | const git = (...args: string[]) => |
| 131 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 132 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 132 | 133 | Bun.spawnSync(["git", "init", "-q", "-b", "main", dir]); |
| 133 | 134 | git("commit", "-q", "--allow-empty", "-m", "start"); |
| 134 | 135 | git("checkout", "-q", "-b", "feature"); |
test/gate-look-note.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterEach, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { tmpdir } from "node:os"; |
| @@ -14,7 +15,7 @@ afterEach(() => { | ||
| 14 | 15 | }); |
| 15 | 16 | |
| 16 | 17 | function sh(cwd: string, ...args: string[]): string { |
| 17 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { cwd }); | |
| 18 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), cwd }); | |
| 18 | 19 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 19 | 20 | return r.stdout.toString().trim(); |
| 20 | 21 | } |
test/gate-readme-cap.test.ts +2 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | /** The gate refuses a pull that adds a section to, or grows, README.md (#12392). */ |
| 2 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 2 | 3 | import { afterEach, expect, test } from "bun:test"; |
| 3 | 4 | import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 4 | 5 | import { tmpdir } from "node:os"; |
| @@ -39,7 +40,7 @@ test("the gate judges README.md against the pull's base in a real repository", a | ||
| 39 | 40 | const dir = mkdtempSync(join(tmpdir(), "forge-readme-")); |
| 40 | 41 | dirs.push(dir); |
| 41 | 42 | const sh = (...a: string[]) => { |
| 42 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...a], { cwd: dir }); | |
| 43 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...a], { env: gitClientEnv(), cwd: dir }); | |
| 43 | 44 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 44 | 45 | return r.stdout.toString().trim(); |
| 45 | 46 | }; |
test/gate-update-pull.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { join } from "node:path"; |
| @@ -8,7 +9,7 @@ const root = mkdtempSync(join(tmpdir(), "gate-update-")); | ||
| 8 | 9 | afterAll(() => rmSync(root, { recursive: true, force: true })); |
| 9 | 10 | |
| 10 | 11 | const git = (cwd: string, ...args: string[]) => { |
| 11 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 12 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 12 | 13 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 13 | 14 | return r.stdout.toString().trim(); |
| 14 | 15 | }; |
test/git-spawn-failure.test.ts +2 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | /** A git that cannot start is an error on one request, never the end of the forge (#12138). */ |
| 2 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 2 | 3 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 4 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 5 | import { tmpdir } from "node:os"; |
| @@ -24,7 +25,7 @@ test("a spawn that throws is an Err on every helper, not a rejection", async () | ||
| 24 | 25 | expect(cap.code).not.toBe(0); |
| 25 | 26 | expect(cap.stderr).toBe("This repository is unavailable."); |
| 26 | 27 | expect(cap.stderr).not.toContain(gone); |
| 27 | const local = await runLocal(["status"], { cwd: gone }); | |
| 28 | const local = await runLocal(["status"], { env: gitClientEnv(), cwd: gone }); | |
| 28 | 29 | expect(local.ok).toBe(false); |
| 29 | 30 | }); |
| 30 | 31 |
test/guest-contribute.test.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * sign-up to a person landing the change. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 8 | 9 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 9 | 10 | import { mkdtemp, rm } from "node:fs/promises"; |
| 10 | 11 | import { tmpdir } from "node:os"; |
| @@ -549,7 +550,7 @@ describe("a guest helps build a public repository", () => { | ||
| 549 | 550 | const auth = `http.extraHeader=Authorization: Basic ${Buffer.from(`${user.username}:${token}`).toString("base64")}`; |
| 550 | 551 | // The forge answers in this process, so git runs beside it, never blocking it. |
| 551 | 552 | const run = (cwd: string, ...a: string[]) => |
| 552 | Bun.spawn(["git", "-c", auth, "-c", "user.name=a", "-c", "user.email=a@a", ...a], { cwd, stdout: "ignore", stderr: "ignore" }).exited; | |
| 553 | Bun.spawn(["git", "-c", auth, "-c", "user.name=a", "-c", "user.email=a@a", ...a], { env: gitClientEnv(), cwd, stdout: "ignore", stderr: "ignore" }).exited; | |
| 553 | 554 | expect(await run(work, "clone", `${servers.url}/${mine}.git`, "w")).toBe(0); |
| 554 | 555 | const tree = join(work, "w"); |
| 555 | 556 | await Bun.write(join(tree, "GIT.md"), "pushed\n"); |
test/helpers/build-standin-builder.ts +2 −1
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | * given: edit, run the app's own tests, and only then commit and push. |
| 4 | 4 | * Argument: the file holding the prompt. |
| 5 | 5 | */ |
| 6 | import { gitClientEnv } from "./git-client.ts"; | |
| 6 | 7 | import { readFileSync, writeFileSync } from "node:fs"; |
| 7 | 8 | import { ANCHOR, READING_V1, READING_V2, routeFor, testFor } from "./build-standin.ts"; |
| 8 | 9 | |
| @@ -13,7 +14,7 @@ const finish = (ok: boolean, result: string): void => | ||
| 13 | 14 | JSON.stringify({ type: "result", subtype: ok ? "success" : "error_during_execution", is_error: !ok, result, total_cost_usd: 0.01, num_turns: 1, session_id: "build-1", terminal_reason: ok ? "completed" : "tool_error" }), |
| 14 | 15 | ); |
| 15 | 16 | const git = (...args: string[]): void => { |
| 16 | const r = Bun.spawnSync(["git", ...args], { stdout: "pipe", stderr: "pipe" }); | |
| 17 | const r = Bun.spawnSync(["git", ...args], { env: gitClientEnv(), stdout: "pipe", stderr: "pipe" }); | |
| 17 | 18 | if (r.exitCode !== 0) throw new Error(`${args.join(" ")}: ${r.stderr.toString()}`); |
| 18 | 19 | }; |
| 19 | 20 |
test/helpers/stranger-builder.ts +2 −1
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * that already has the route (a reviewer's clone, a second run), changes |
| 8 | 8 | * nothing and says so. Argument: none; the prompt is read from stdin. |
| 9 | 9 | */ |
| 10 | import { gitClientEnv } from "./git-client.ts"; | |
| 10 | 11 | import { readFileSync, writeFileSync } from "node:fs"; |
| 11 | 12 | import { ANCHOR } from "./build-standin.ts"; |
| 12 | 13 | |
| @@ -51,7 +52,7 @@ const finish = (ok: boolean, result: string): void => | ||
| 51 | 52 | }), |
| 52 | 53 | ); |
| 53 | 54 | const git = (...args: string[]): void => { |
| 54 | const r = Bun.spawnSync(["git", ...args], { stdout: "pipe", stderr: "pipe" }); | |
| 55 | const r = Bun.spawnSync(["git", ...args], { env: gitClientEnv(), stdout: "pipe", stderr: "pipe" }); | |
| 55 | 56 | if (r.exitCode !== 0) throw new Error(`${args.join(" ")}: ${r.stderr.toString()}`); |
| 56 | 57 | }; |
| 57 | 58 |
test/lands-once.test.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * tree is the base's own commits nothing: the pull closes as merged into |
| 7 | 7 | * the commit that already carried it. |
| 8 | 8 | */ |
| 9 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 9 | 10 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 10 | 11 | import { mkdtemp, rm } from "node:fs/promises"; |
| 11 | 12 | import { tmpdir } from "node:os"; |
| @@ -29,7 +30,7 @@ describe("a pull lands once", () => { | ||
| 29 | 30 | let repo: Repo; |
| 30 | 31 | const fresh = () => getRepoById(app.db, repo.id)!; |
| 31 | 32 | const git = (...args: string[]) => |
| 32 | Bun.spawnSync(["git", ...args], { | |
| 33 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), | |
| 33 | 34 | cwd: repoDir(app.reposRoot, repo.ownerName, repo.name), |
| 34 | 35 | }) |
| 35 | 36 | .stdout.toString() |
test/log-tail-view.test.ts +2 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | /** A .log or .txt over 5 MB opens its last 1,000 lines, and says what it left out (#13603). */ |
| 2 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 2 | 3 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 3 | 4 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 5 | import { tmpdir } from "node:os"; |
| @@ -17,7 +18,7 @@ let dir = ""; | ||
| 17 | 18 | beforeAll(async () => { |
| 18 | 19 | dir = await mkdtemp(join(tmpdir(), "forge-tail-")); |
| 19 | 20 | const git = (args: string[], stdin?: Uint8Array): string => { |
| 20 | const r = Bun.spawnSync(["git", ...args], { cwd: dir, stdin: stdin ?? "ignore" }); | |
| 21 | const r = Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: dir, stdin: stdin ?? "ignore" }); | |
| 21 | 22 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 22 | 23 | return r.stdout.toString().trim(); |
| 23 | 24 | }; |
test/merge-queue-batch.test.ts +2 −1
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * time, so "at once" is counted, never timed; it reads the candidate's tree: |
| 8 | 8 | * red when it holds `bad.txt`. |
| 9 | 9 | */ |
| 10 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 10 | 11 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 11 | 12 | import { mkdtemp, rm } from "node:fs/promises"; |
| 12 | 13 | import { tmpdir } from "node:os"; |
| @@ -22,7 +23,7 @@ describe("the merge queue's batch size", () => { | ||
| 22 | 23 | let landings = 0; |
| 23 | 24 | |
| 24 | 25 | const git = (...args: string[]) => |
| 25 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 26 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 26 | 27 | |
| 27 | 28 | beforeAll(async () => { |
| 28 | 29 | dir = await mkdtemp(join(tmpdir(), "forge-merge-queue-batch-")); |
test/merge-queue-check-retry.test.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * the batch lands whole with nothing bisected; red again, it is searched, |
| 6 | 6 | * and the search's own prefixes are not gated twice. |
| 7 | 7 | */ |
| 8 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 8 | 9 | import { afterAll, afterEach, beforeAll, describe, expect, spyOn, test } from "bun:test"; |
| 9 | 10 | import { mkdtemp, rm } from "node:fs/promises"; |
| 10 | 11 | import { tmpdir } from "node:os"; |
| @@ -22,7 +23,7 @@ describe("the merge queue gates a red (check) once more before it searches", () | ||
| 22 | 23 | let floor: LogLevel; |
| 23 | 24 | |
| 24 | 25 | const git = (...args: string[]) => |
| 25 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 26 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 26 | 27 | |
| 27 | 28 | beforeAll(async () => { |
| 28 | 29 | dir = await mkdtemp(join(tmpdir(), "forge-merge-queue-check-retry-")); |
test/merge-queue-clash.test.ts +2 −1
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * pulls again; a push forgets it. The gate here reads the candidate's |
| 8 | 8 | * tree: red when it holds both `a.txt` and `b.txt`. |
| 9 | 9 | */ |
| 10 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 10 | 11 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 11 | 12 | import { mkdtemp, rm } from "node:fs/promises"; |
| 12 | 13 | import { tmpdir } from "node:os"; |
| @@ -23,7 +24,7 @@ describe("the merge queue remembers clashes", () => { | ||
| 23 | 24 | const told: { pull: number; together: number[] }[] = []; |
| 24 | 25 | |
| 25 | 26 | const git = (...args: string[]) => |
| 26 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 27 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 27 | 28 | |
| 28 | 29 | beforeAll(async () => { |
| 29 | 30 | dir = await mkdtemp(join(tmpdir(), "forge-merge-queue-clash-")); |
test/merge-queue-gate-result.test.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * and `GET …/queue/gates` and the `queue_gates` MCP tool answer them. A test |
| 7 | 7 | * red in two gates that share no pull is flagged flaky. |
| 8 | 8 | */ |
| 9 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 9 | 10 | import { afterAll, beforeAll, describe, expect, spyOn, test } from "bun:test"; |
| 10 | 11 | import { mkdtemp, rm } from "node:fs/promises"; |
| 11 | 12 | import { tmpdir } from "node:os"; |
| @@ -127,7 +128,7 @@ describe("the merge queue keeps and names each gate's failing tests", () => { | ||
| 127 | 128 | const spies: { mockRestore(): void }[] = []; |
| 128 | 129 | |
| 129 | 130 | const git = (repo: Repo, ...args: string[]) => |
| 130 | Bun.spawnSync(["git", ...args], { cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 131 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 131 | 132 | .stdout.toString() |
| 132 | 133 | .trim(); |
| 133 | 134 |
test/merge-queue-parallel.test.ts +3 −2
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * gate the wave should hold has started, so "at once" is counted, never |
| 8 | 8 | * timed. It goes red on any tree holding a `red-*` file. |
| 9 | 9 | */ |
| 10 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 10 | 11 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 11 | 12 | import { mkdtemp, rm } from "node:fs/promises"; |
| 12 | 13 | import { tmpdir } from "node:os"; |
| @@ -45,7 +46,7 @@ describe("the merge queue in parallel", () => { | ||
| 45 | 46 | let wave = 0; |
| 46 | 47 | |
| 47 | 48 | const git = (repo: Repo, ...args: string[]) => |
| 48 | Bun.spawnSync(["git", ...args], { cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 49 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 49 | 50 | .stdout.toString() |
| 50 | 51 | .trim(); |
| 51 | 52 | |
| @@ -235,7 +236,7 @@ describe("the queue's extra gates and the pull checks' slots", () => { | ||
| 235 | 236 | let app: App; |
| 236 | 237 | let checks: ChecksHandle | undefined; |
| 237 | 238 | const git = (...args: string[]) => |
| 238 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 239 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 239 | 240 | |
| 240 | 241 | beforeAll(async () => { |
| 241 | 242 | dataDir = await mkdtemp(join(tmpdir(), "forge-merge-queue-slots-")); |
test/merge-queue-reason.test.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * bisected. A pull that conflicts with an earlier one of its batch is left |
| 6 | 6 | * out, named with it, and the rest land in that one gate. |
| 7 | 7 | */ |
| 8 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 8 | 9 | import { afterAll, afterEach, beforeAll, describe, expect, spyOn, test } from "bun:test"; |
| 9 | 10 | import { mkdtemp, rm } from "node:fs/promises"; |
| 10 | 11 | import { tmpdir } from "node:os"; |
| @@ -54,7 +55,7 @@ describe("the merge queue acts on why a gate went red", () => { | ||
| 54 | 55 | const spies: { mockRestore(): void }[] = []; |
| 55 | 56 | |
| 56 | 57 | const git = (...args: string[]) => |
| 57 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 58 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 58 | 59 | |
| 59 | 60 | beforeAll(async () => { |
| 60 | 61 | dir = await mkdtemp(join(tmpdir(), "forge-merge-queue-reason-")); |
test/merge-queue-restart.test.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * gated again on the same base — and never plans the line from nothing. |
| 7 | 7 | * The lane here is a stand-in the test holds open and lets go of. |
| 8 | 8 | */ |
| 9 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 9 | 10 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 10 | 11 | import { mkdtemp, rm } from "node:fs/promises"; |
| 11 | 12 | import { tmpdir } from "node:os"; |
| @@ -39,7 +40,7 @@ describe("the merge queue across a restart", () => { | ||
| 39 | 40 | let lost = false; |
| 40 | 41 | |
| 41 | 42 | const git = (repo: Repo, ...args: string[]) => |
| 42 | Bun.spawnSync(["git", ...args], { cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 43 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }) | |
| 43 | 44 | .stdout.toString() |
| 44 | 45 | .trim(); |
| 45 | 46 |
test/merge-queue-revert-alone.test.ts +2 −1
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | * A lane revert (`checks/revert_lane.ts`, `Queued.alone`) gates alone and first in the merge |
| 3 | 3 | * queue's line: it joins no batch, and the line's other pulls batch as before behind it. |
| 4 | 4 | */ |
| 5 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 5 | 6 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 6 | 7 | import { mkdtemp, rm } from "node:fs/promises"; |
| 7 | 8 | import { tmpdir } from "node:os"; |
| @@ -11,7 +12,7 @@ import type { LandVerdict } from "../src/checks/tiers.ts"; | ||
| 11 | 12 | import type { Pull } from "../src/core/pulls.ts"; |
| 12 | 13 | |
| 13 | 14 | let dir: string; |
| 14 | const git = (...args: string[]) => Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 15 | const git = (...args: string[]) => Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 15 | 16 | |
| 16 | 17 | beforeAll(async () => { |
| 17 | 18 | dir = await mkdtemp(join(tmpdir(), "forge-merge-queue-alone-")); |
test/merge-queue-search.test.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * gate here is held open and let go a wave at a time, so "at once" is counted, |
| 6 | 6 | * never timed; it reads the candidate's tree: red when it holds `bad.txt`. |
| 7 | 7 | */ |
| 8 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 8 | 9 | import { afterEach, beforeEach, describe, expect, test } from "bun:test"; |
| 9 | 10 | import { mkdtemp, rm } from "node:fs/promises"; |
| 10 | 11 | import { tmpdir } from "node:os"; |
| @@ -24,7 +25,7 @@ describe("the merge queue searches a red candidate by stacked prefixes", () => { | ||
| 24 | 25 | const last = args[args.length - 1]; |
| 25 | 26 | const input = typeof last === "object" ? last.input : undefined; |
| 26 | 27 | const words = args.filter((a): a is string => typeof a === "string"); |
| 27 | return Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...words], { stdin: input === undefined ? undefined : Buffer.from(input) }) | |
| 28 | return Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...words], { env: gitClientEnv(), stdin: input === undefined ? undefined : Buffer.from(input) }) | |
| 28 | 29 | .stdout.toString() |
| 29 | 30 | .trim(); |
| 30 | 31 | }; |
test/merge-queue-suspect.test.ts +3 −2
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * batches waits for a verdict of its own and never heads a third. The gate |
| 6 | 6 | * here reads the candidate's tree: red when it holds `bad.txt`. |
| 7 | 7 | */ |
| 8 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 8 | 9 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 9 | 10 | import { mkdtemp, rm } from "node:fs/promises"; |
| 10 | 11 | import { tmpdir } from "node:os"; |
| @@ -20,7 +21,7 @@ describe("the merge queue judges a suspect alone", () => { | ||
| 20 | 21 | const told: { pull: number; together: number[] }[] = []; |
| 21 | 22 | |
| 22 | 23 | const git = (...args: string[]) => |
| 23 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 24 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 24 | 25 | |
| 25 | 26 | beforeAll(async () => { |
| 26 | 27 | dir = await mkdtemp(join(tmpdir(), "forge-merge-queue-suspect-")); |
| @@ -36,7 +37,7 @@ describe("the merge queue judges a suspect alone", () => { | ||
| 36 | 37 | function headAdding(file: string): string { |
| 37 | 38 | // Plumbing only (three spawns, no checkout): main's tree plus one blob. |
| 38 | 39 | const run = (input: string, ...args: string[]) => |
| 39 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { stdin: Buffer.from(input) }) | |
| 40 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), stdin: Buffer.from(input) }) | |
| 40 | 41 | .stdout.toString().trim(); |
| 41 | 42 | const blob = run(`${file}\n`, "hash-object", "-w", "--stdin"); |
| 42 | 43 | // The replace drops the leading newline when main's tree is empty. |
test/merge-queue.test.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * green part and hands the culprit back. The gate here is a stand-in that |
| 6 | 6 | * counts its runs and goes red on any tree holding a `red-*` file. |
| 7 | 7 | */ |
| 8 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 8 | 9 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 9 | 10 | import { mkdtemp, rm } from "node:fs/promises"; |
| 10 | 11 | import { tmpdir } from "node:os"; |
| @@ -61,7 +62,7 @@ describe("the merge queue", () => { | ||
| 61 | 62 | let atGate: (() => void) | undefined; |
| 62 | 63 | |
| 63 | 64 | const git = (repo: Repo, ...args: string[]) => |
| 64 | Bun.spawnSync(["git", ...args], { | |
| 65 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), | |
| 65 | 66 | cwd: repoDir(app.reposRoot, repo.ownerName, repo.name), |
| 66 | 67 | }) |
| 67 | 68 | .stdout.toString() |
test/orphan-clones.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { describe, expect, test } from "bun:test"; |
| 2 | 3 | import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { tmpdir } from "node:os"; |
| @@ -63,7 +64,7 @@ describe("trimming idle clones' installed packages (#13514)", () => { | ||
| 63 | 64 | |
| 64 | 65 | describe("removing clones idle for a day (#13734, #14007)", () => { |
| 65 | 66 | const git = (cwd: string, ...args: string[]): void => { |
| 66 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 67 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 67 | 68 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 68 | 69 | }; |
| 69 | 70 | const age = async (dir: string, days: number, also: string[] = []): Promise<void> => { |
test/path-listing.test.ts +2 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | /** Path listings kept by tree id: a second ask reuses the first, a moved branch never reads stale. */ |
| 2 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 2 | 3 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 4 | import { mkdtemp, rm, writeFile } from "node:fs/promises"; |
| 4 | 5 | import { tmpdir } from "node:os"; |
| @@ -8,7 +9,7 @@ import { closeReader } from "../src/git/read.ts"; | ||
| 8 | 9 | |
| 9 | 10 | let dir: string; |
| 10 | 11 | const git = (...args: string[]) => { |
| 11 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { cwd: dir }); | |
| 12 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), cwd: dir }); | |
| 12 | 13 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 13 | 14 | }; |
| 14 | 15 | const commit = async (file: string) => { |
test/pin-refusal.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, expect, test } from "bun:test"; |
| 2 | 3 | import { TOOK_LINE } from "../src/checks/took_line.ts"; |
| 3 | 4 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| @@ -12,7 +13,7 @@ afterAll(() => rmSync(root, { recursive: true, force: true })); | ||
| 12 | 13 | |
| 13 | 14 | const gateScript = join(import.meta.dir, "../scripts/gate.ts"); |
| 14 | 15 | const run = (cwd: string, ...args: string[]) => { |
| 15 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 16 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 16 | 17 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 17 | 18 | return r.stdout.toString().trim(); |
| 18 | 19 | }; |
test/queue-verdicts.test.ts +2 −1
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | * back with its failing tests, or calls the red the machine's, and says so |
| 4 | 4 | * in the keeper, the flow reading and the boards' sources. |
| 5 | 5 | */ |
| 6 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 6 | 7 | import { afterAll, afterEach, beforeAll, describe, expect, spyOn, test } from "bun:test"; |
| 7 | 8 | import { mkdtemp, rm } from "node:fs/promises"; |
| 8 | 9 | import { tmpdir } from "node:os"; |
| @@ -23,7 +24,7 @@ describe("the merge queue says what a red batch was", () => { | ||
| 23 | 24 | const kept: QueueVerdict[] = []; |
| 24 | 25 | const spies: { mockRestore(): void }[] = []; |
| 25 | 26 | const git = (...args: string[]) => |
| 26 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args]).stdout.toString().trim(); | |
| 27 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv() }).stdout.toString().trim(); | |
| 27 | 28 | |
| 28 | 29 | beforeAll(async () => { |
| 29 | 30 | dir = await mkdtemp(join(tmpdir(), "forge-queue-verdicts-")); |
test/red-on-main.test.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * |
| 7 | 7 | * @not-a-tree-scan: the scans it writes list only their own scratch repository's src. |
| 8 | 8 | */ |
| 9 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 9 | 10 | import { describe, expect, test } from "bun:test"; |
| 10 | 11 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 11 | 12 | import { tmpdir } from "node:os"; |
| @@ -240,7 +241,7 @@ describe("the fast tier asks main", () => { | ||
| 240 | 241 | const pass = `import { test } from "bun:test";\ntest("ok", () => {});\n`; |
| 241 | 242 | const fail = `import { expect, test } from "bun:test";\ntest("red", () => { expect(1).toBe(2); });\n`; |
| 242 | 243 | const git = (dir: string, ...args: string[]): number => |
| 243 | Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { | |
| 244 | Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), | |
| 244 | 245 | cwd: dir, |
| 245 | 246 | stdout: "ignore", |
| 246 | 247 | stderr: "ignore", |
test/release-subject.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { tmpdir } from "node:os"; |
| @@ -9,7 +10,7 @@ let release: string; | ||
| 9 | 10 | let plain: string; |
| 10 | 11 | |
| 11 | 12 | function git(...args: string[]): string { |
| 12 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd: dir }); | |
| 13 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd: dir }); | |
| 13 | 14 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 14 | 15 | return r.stdout.toString().trim(); |
| 15 | 16 | } |
test/repo-delete-forks.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 2 | 3 | import { chmod, mkdtemp, rm } from "node:fs/promises"; |
| 3 | 4 | import { existsSync } from "node:fs"; |
| @@ -17,7 +18,7 @@ import type { Repo } from "../src/core/repos.ts"; | ||
| 17 | 18 | */ |
| 18 | 19 | |
| 19 | 20 | const git = async (cwd: string, ...args: string[]) => { |
| 20 | const p = Bun.spawn(["git", ...args], { cwd, stdout: "pipe", stderr: "pipe" }); | |
| 21 | const p = Bun.spawn(["git", ...args], { env: gitClientEnv(), cwd, stdout: "pipe", stderr: "pipe" }); | |
| 21 | 22 | const [out, code] = await Promise.all([new Response(p.stdout).text(), p.exited]); |
| 22 | 23 | return { out: out.trim(), code }; |
| 23 | 24 | }; |
test/revert-gate.test.ts +2 −1
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | * pull row reverts a merged pull and its change is exactly that landing's inverse) and those two |
| 5 | 5 | * rules stand down. A pull that is not that revert is still held to both. |
| 6 | 6 | */ |
| 7 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 7 | 8 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 8 | 9 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 9 | 10 | import { tmpdir } from "node:os"; |
| @@ -97,7 +98,7 @@ describe("the gate stands down two rules for a marked revert", () => { | ||
| 97 | 98 | const root = mkdtempSync(join(tmpdir(), "revert-gate-")); |
| 98 | 99 | afterAll(() => rmSync(root, { recursive: true, force: true })); |
| 99 | 100 | const run = (cwd: string, ...args: string[]) => { |
| 100 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 101 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 101 | 102 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 102 | 103 | return r.stdout.toString().trim(); |
| 103 | 104 | }; |
test/scripts-fast.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { tmpdir } from "node:os"; |
| @@ -63,7 +64,7 @@ function repo(): string { | ||
| 63 | 64 | const git = (...args: string[]): void => { |
| 64 | 65 | const run = Bun.spawnSync( |
| 65 | 66 | ["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], |
| 66 | { cwd: dir }, | |
| 67 | { env: gitClientEnv(), cwd: dir }, | |
| 67 | 68 | ); |
| 68 | 69 | if (run.exitCode !== 0) throw new Error(run.stderr.toString()); |
| 69 | 70 | }; |
test/search-grep-stops.test.ts +2 −1
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | // #10395: `git grep --max-count` is per file, so a one-letter query in a |
| 2 | 2 | // repository of many files wrote megabytes that the forge read whole on its |
| 3 | 3 | // event loop. The read now stops git once the hits it keeps are in. |
| 4 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 4 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 5 | 6 | import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 6 | 7 | import { tmpdir } from "node:os"; |
| @@ -17,7 +18,7 @@ beforeAll(() => { | ||
| 17 | 18 | const line = "a line that matches a\n"; |
| 18 | 19 | for (let i = 0; i < FILES; i++) writeFileSync(join(dir, `f${i}.txt`), line.repeat(LINES)); |
| 19 | 20 | const git = (...args: string[]) => { |
| 20 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "[email protected]", ...args], { cwd: dir }); | |
| 21 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "[email protected]", ...args], { env: gitClientEnv(), cwd: dir }); | |
| 21 | 22 | if (r.exitCode !== 0) throw new Error(`git ${args[0]}: ${r.stderr.toString()}`); |
| 22 | 23 | }; |
| 23 | 24 | git("init", "--quiet", "--initial-branch=main"); |
test/shards-run.test.ts +2 −1
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * @not-a-tree-scan: it lists only its own temporary directories, and what |
| 8 | 8 | * it takes from scripts/gate.ts does not read the tree. |
| 9 | 9 | */ |
| 10 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 10 | 11 | import { afterAll, describe, expect, test } from "bun:test"; |
| 11 | 12 | import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 12 | 13 | import { tmpdir } from "node:os"; |
| @@ -152,7 +153,7 @@ describe("the gate audit before any shard", () => { | ||
| 152 | 153 | const script = new URL("../scripts/test-shards.ts", import.meta.url).pathname; |
| 153 | 154 | const listed = presentTests(); |
| 154 | 155 | const git = (dir: string, ...args: string[]) => |
| 155 | Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { | |
| 156 | Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), | |
| 156 | 157 | cwd: dir, |
| 157 | 158 | stdout: "ignore", |
| 158 | 159 | stderr: "ignore", |
test/spawn-argv.test.ts +1 −1
| @@ -285,7 +285,7 @@ function audit(sites: Site[], list: Allowed[]): { loose: string[]; miscounted: s | ||
| 285 | 285 | describe("what the scan reads", () => { |
| 286 | 286 | test("a literal or constant program is fixed; a variable or a template with a value is not", () => { |
| 287 | 287 | const src = [ |
| 288 | `const SETSID = Bun.which("setsid"); Bun.spawn(["git", ...args], { cwd });`, | |
| 288 | `const SETSID = Bun.which("setsid"); Bun.spawn(["git", ...args], { env: gitClientEnv(), cwd });`, | |
| 289 | 289 | `Bun.spawnSync([process.execPath, "x.ts"]);`, |
| 290 | 290 | `Bun.spawn([SETSID, "-c", ...argv]);`, |
| 291 | 291 | `Bun.spawn(argv, {});`, |
test/spawn-template-birth.test.ts +2 −1
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | * adds nothing more, and nothing of the parent travels. |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 7 | 8 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 8 | 9 | import { mkdtemp, readdir, rm } from "node:fs/promises"; |
| 9 | 10 | import { tmpdir } from "node:os"; |
| @@ -50,7 +51,7 @@ describe("a forge made from a template", () => { | ||
| 50 | 51 | return childDirOf(parent, r.value.bodyId); |
| 51 | 52 | }; |
| 52 | 53 | const git = (childDir: string, org: string, repo: string, ...args: string[]) => |
| 53 | Bun.spawnSync(["git", ...args], { cwd: repoDir(join(childDir, "repos"), org, repo) }).stdout.toString(); | |
| 54 | Bun.spawnSync(["git", ...args], { env: gitClientEnv(), cwd: repoDir(join(childDir, "repos"), org, repo) }).stdout.toString(); | |
| 54 | 55 | const repos = (childDir: string, org: string) => readdir(join(childDir, "repos", org)).catch(() => [] as string[]); |
| 55 | 56 | |
| 56 | 57 | beforeAll(async () => { |
test/tags-etag.test.ts +2 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | /** GET /api/v1/repos/:owner/:name/tags carries an ETag and answers a repeat with 304 (#9161). */ |
| 2 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 2 | 3 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 4 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 5 | import { tmpdir } from "node:os"; |
| @@ -22,7 +23,7 @@ const cells = process.env["FORGE_CELLS"]; | ||
| 22 | 23 | const URL_ = "/api/v1/repos/alice/r/tags"; |
| 23 | 24 | |
| 24 | 25 | const git = async (...args: string[]): Promise<string> => { |
| 25 | const p = Bun.spawn(["git", "-c", "user.name=t", "-c", "[email protected]", "--git-dir", dir, ...args], { stdout: "pipe", stderr: "pipe" }); | |
| 26 | const p = Bun.spawn(["git", "-c", "user.name=t", "-c", "[email protected]", "--git-dir", dir, ...args], { env: gitClientEnv(), stdout: "pipe", stderr: "pipe" }); | |
| 26 | 27 | const out = await new Response(p.stdout).text(); |
| 27 | 28 | if ((await p.exited) !== 0) throw new Error(await new Response(p.stderr).text()); |
| 28 | 29 | return out.trim(); |
test/template-scripts.test.ts +2 −1
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | * scripts/take-template.ts and scripts/birth-check.ts (#10305): the only |
| 3 | 3 | * checks that a template change still bundles and still boots. |
| 4 | 4 | */ |
| 5 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 5 | 6 | import { afterAll, beforeAll, expect, setDefaultTimeout, test } from "bun:test"; |
| 6 | 7 | import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; |
| 7 | 8 | import { tmpdir } from "node:os"; |
| @@ -12,7 +13,7 @@ setDefaultTimeout(60_000); | ||
| 12 | 13 | |
| 13 | 14 | let root: string; |
| 14 | 15 | const git = (dir: string, ...args: string[]) => |
| 15 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { stdout: "pipe", stderr: "pipe" }); | |
| 16 | Bun.spawnSync(["git", "-C", dir, "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), stdout: "pipe", stderr: "pipe" }); | |
| 16 | 17 | |
| 17 | 18 | async function checkout(name: string, extra: Record<string, Uint8Array | string> = {}): Promise<string> { |
| 18 | 19 | const dir = join(root, name); |
test/test-budget-run.test.ts +2 −1
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | * @not-a-tree-scan: it lists only the repository's test names, to make an |
| 9 | 9 | * audit-clean fixture, and reads nothing else of the tree. |
| 10 | 10 | */ |
| 11 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 11 | 12 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 12 | 13 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 13 | 14 | import { tmpdir } from "node:os"; |
| @@ -18,7 +19,7 @@ const script = new URL("../scripts/test-shards.ts", import.meta.url).pathname; | ||
| 18 | 19 | let dir = ""; |
| 19 | 20 | |
| 20 | 21 | const git = (...args: string[]): number => |
| 21 | Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { | |
| 22 | Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], { env: gitClientEnv(), | |
| 22 | 23 | cwd: dir, |
| 23 | 24 | stdout: "ignore", |
| 24 | 25 | stderr: "ignore", |
test/test-git-env.test.ts added +45
| @@ -0,0 +1,45 @@ | ||
| 1 | /** | |
| 2 | * A test's git child gets a built environment, never the host's (CLAUDE.md: `gitClientEnv`). A | |
| 3 | * helper that spawns git with the caller's verb (`["git", ...args]`) and no `env` hands git the | |
| 4 | * machine's own configuration: `fetch.prune` in a developer's global gitconfig made two of | |
| 5 | * test/dev-cell.test.ts's tests fail on that machine and nowhere else. | |
| 6 | * | |
| 7 | * Every such spawn passes `env: gitClientEnv()` (test/helpers/git-client.ts); a new one without it | |
| 8 | * fails here. | |
| 9 | */ | |
| 10 | import { expect, test } from "bun:test"; | |
| 11 | import { readdirSync, readFileSync } from "node:fs"; | |
| 12 | import { join } from "node:path"; | |
| 13 | ||
| 14 | /** Whether `source` spawns git with a caller's arguments (or through `runLocal`) and no env. */ | |
| 15 | function spawnsGitOnHostEnv(source: string): boolean { | |
| 16 | for (const m of source.matchAll(/\b(?:Bun\.spawn(?:Sync)?|runLocal)\(/g)) { | |
| 17 | let depth = 0; | |
| 18 | let i = source.indexOf("(", m.index); | |
| 19 | const start = i; | |
| 20 | for (; i < source.length; i++) { | |
| 21 | if (source[i] === "(") depth++; | |
| 22 | else if (source[i] === ")" && --depth === 0) break; | |
| 23 | } | |
| 24 | const call = source.slice(start, i); | |
| 25 | const git = m[0].startsWith("runLocal") || /^\(\s*\[\s*"git"/.test(call); | |
| 26 | if (!git || /\benv\b/.test(call)) continue; | |
| 27 | if (m[0].startsWith("runLocal") || /^\(\s*\[\s*"git"[^\]]*\.\.\.\w+/.test(call)) return true; | |
| 28 | } | |
| 29 | return false; | |
| 30 | } | |
| 31 | ||
| 32 | test("no test spawns git on the host's environment", () => { | |
| 33 | const dir = import.meta.dir; | |
| 34 | const files = readdirSync(dir, { recursive: true }).map(String).filter((f) => f.endsWith(".ts")).sort(); | |
| 35 | // This file names the pattern in its own examples. Each one found: pass `env: gitClientEnv()`. | |
| 36 | expect(files.filter((f) => f !== "test-git-env.test.ts" && spawnsGitOnHostEnv(readFileSync(join(dir, f), "utf8")))).toEqual([]); | |
| 37 | }); | |
| 38 | ||
| 39 | test("the detector sees a bare helper, and spares one with its own env or a fixed verb", () => { | |
| 40 | expect(spawnsGitOnHostEnv('const git = (...args: string[]) => Bun.spawnSync(["git", ...args], { cwd });')).toBe(true); | |
| 41 | expect(spawnsGitOnHostEnv('await runLocal(["fetch", ...args], { cwd });')).toBe(true); | |
| 42 | expect(spawnsGitOnHostEnv('Bun.spawnSync(["git", ...args], { cwd, env: gitClientEnv() });')).toBe(false); | |
| 43 | expect(spawnsGitOnHostEnv('Bun.spawnSync(["git", "rev-parse", "HEAD"], { cwd });')).toBe(false); | |
| 44 | expect(spawnsGitOnHostEnv('await runLocal(["fetch"], { cwd, env: gitClientEnv() });')).toBe(false); | |
| 45 | }); |
test/tests-with-change.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { expect, test } from "bun:test"; |
| 2 | 3 | import { testsWithChangeProblems } from "../src/kernel/tests_with_change.ts"; |
| 3 | 4 | import { testsWithChangeRefusal } from "../scripts/gate.ts"; |
| @@ -32,7 +33,7 @@ test("the gate judges a real commit range from FORGE_CHECK_BASE", async () => { | ||
| 32 | 33 | const saved = process.env.FORGE_CHECK_BASE; |
| 33 | 34 | try { |
| 34 | 35 | const sh = (...a: string[]) => { |
| 35 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...a], { cwd: dir }); | |
| 36 | const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...a], { env: gitClientEnv(), cwd: dir }); | |
| 36 | 37 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 37 | 38 | return r.stdout.toString().trim(); |
| 38 | 39 | }; |
test/try-it.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 4 | import { join } from "node:path"; |
| @@ -67,7 +68,7 @@ const root = mkdtempSync(join(tmpdir(), "try-it-")); | ||
| 67 | 68 | afterAll(() => rmSync(root, { recursive: true, force: true })); |
| 68 | 69 | |
| 69 | 70 | const git = (cwd: string, ...args: string[]) => { |
| 70 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); | |
| 71 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { env: gitClientEnv(), cwd }); | |
| 71 | 72 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| 72 | 73 | return r.stdout.toString().trim(); |
| 73 | 74 | }; |
test/tui-forks-take.test.ts +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 1 | 2 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 2 | 3 | import { mkdtemp, rm } from "node:fs/promises"; |
| 3 | 4 | import { tmpdir } from "node:os"; |
| @@ -76,7 +77,7 @@ describe("the terminal's forks screen takes the parent's updates with t", () => | ||
| 76 | 77 | const behind = async (owner: string) => |
| 77 | 78 | (await forkRelation(app, getRepo(app.db, owner, "app")!, upstream))!.behind; |
| 78 | 79 | const git = async (cwd: string, ...args: string[]) => { |
| 79 | const p = Bun.spawn(["git", ...args], { cwd, stdout: "pipe", stderr: "pipe" }); | |
| 80 | const p = Bun.spawn(["git", ...args], { env: gitClientEnv(), cwd, stdout: "pipe", stderr: "pipe" }); | |
| 80 | 81 | const out = await new Response(p.stdout).text(); |
| 81 | 82 | expect(await p.exited).toBe(0); |
| 82 | 83 | return out.trim(); |
new above
offline
This says "A built environment, never the host's", but
runLocalmergesprocess.envunderneathopts.env(src/git/local.ts:29-41). Env-supplied git config (GIT_CONFIG_COUNT/KEY_n/VALUE_n) still gets through. PassgitClientEnv({ GIT_CONFIG_COUNT: "0" })so the comment is true, or reword it to say only the config files are overridden.