Files
mesh-lab/test/forge.test.ts
T
jochen 7ed7da1398
mesh/merge-gate head 7ed7da1398df merged into trunk 307dd23d6d2a — pass: the change touches no module of the mesh's graph
mesh/repo-check head 7ed7da1398df merged into trunk 307dd23d6d2a — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (typescript)…
mesh/delivery delivered
Let a bed's forge take the lab's shallow checkouts (issue 689)
The lab module clones every repository with --depth 50, and a fresh bare
repository refuses a push whose history ends in a cut, so the genesis bed
raised its anchor and forge and then skipped. The three beds that carry a
checkout into a forge now share one helper that sets receive.shallowUpdate
on the bare repository. Unshallowing instead cannot work in a lab run: the
forge credential is removed once the run's clones are done.
2026-10-14 02:21:21 +02:00

51 lines
2.4 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { carry } from "./integration/forge.ts";
/**
* A bed's forge takes the lab's checkouts as they are: shallow (novox/hq issue 689). The lab module clones
* every repository with `--depth`, and the genesis bed's forge refused the push ("shallow update not
* allowed"), so the bed never reached its installer. Held here with a real git and no lab.
*/
const git = (cwd: string, ...args: string[]) =>
execFileSync("git", ["-C", cwd, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"],
env: { ...process.env, GIT_AUTHOR_NAME: "lab", GIT_AUTHOR_EMAIL: "lab@example.org",
GIT_COMMITTER_NAME: "lab", GIT_COMMITTER_EMAIL: "lab@example.org" } }).trim();
test("a shallow checkout, as the lab clones it, is carried into the bed's forge and served from it", () => {
const dir = mkdtempSync(join(tmpdir(), "mesh-lab-689-"));
try {
const origin = join(dir, "origin");
execFileSync("git", ["init", "-q", "-b", "main", origin]);
for (let i = 0; i < 5; i++) {
writeFileSync(join(origin, "file"), `${i}\n`);
git(origin, "add", "file");
git(origin, "commit", "-q", "-m", `commit ${i}`);
}
// As the lab module clones: shallow, over a transport that honours the depth.
const checkout = join(dir, "checkout");
execFileSync("git", ["clone", "-q", "--depth", "2", "--branch", "main", `file://${origin}`, checkout]);
assert.equal(git(checkout, "rev-parse", "--is-shallow-repository"), "true");
const bare = join(dir, "forge", "repo.git");
const head = carry(checkout, bare, ["main", "lab"]);
assert.equal(head, git(origin, "rev-parse", "HEAD"));
assert.equal(git(bare, "rev-parse", "refs/heads/main"), head);
assert.equal(git(bare, "rev-parse", "refs/heads/lab"), head);
// What the bed's machines do with it: clone over git's protocol, and find the commit under test.
const served = join(dir, "served");
execFileSync("git", ["clone", "-q", "--branch", "main", `file://${bare}`, served]);
assert.equal(git(served, "rev-parse", "HEAD"), head);
assert.equal(git(served, "show", "HEAD:file"), "4");
} finally {
rmSync(dir, { recursive: true, force: true });
}
});