Let a bed's forge take the lab's shallow checkouts (issue 689)
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

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.
This commit is contained in:
jochen
2026-10-14 02:21:21 +02:00
parent 1316a405a6
commit 7ed7da1398
5 changed files with 88 additions and 18 deletions
+31
View File
@@ -0,0 +1,31 @@
/**
* A bed's forge: a checkout's HEAD carried into a fresh bare repository, which a git daemon then serves.
*
* **A shallow checkout is carried as it is** (novox/hq issue 689). The lab module checks every repository
* out shallow, and a fresh bare repository refuses a push whose history ends in a cut ("shallow update not
* allowed"), so the genesis bed raised its anchor and forge and then skipped. The bare repository accepts
* the cut (`receive.shallowUpdate`) and serves the history the checkout holds: the bed serves the commit
* under test, and nothing it raises reads further back than the run's checkout does. Unshallowing first is
* not an option in a lab run: the forge credential is gone once the run's clones are done, so a private
* repository could not be fetched again.
*/
import { execFileSync } from "node:child_process";
/**
* Initialise `bare` and push `checkout`'s HEAD into it under each of `branches`. Returns the commit served.
*/
export function carry(checkout: string, bare: string, branches: string[] = ["main"]): string {
execFileSync("git", ["init", "-q", "--bare", bare]);
// No collection after the push: one run in the background rewrites the objects while they are carried.
execFileSync("git", ["-C", bare, "config", "receive.autogc", "false"]);
// The lab's checkouts are shallow, and a bare repository refuses a shallow push without this.
execFileSync("git", ["-C", bare, "config", "receive.shallowUpdate", "true"]);
const [first, ...rest] = branches;
execFileSync("git", ["-C", checkout, "push", "-q", "--force", bare, `HEAD:refs/heads/${first}`], { stdio: "pipe" });
const head = execFileSync("git", ["-C", checkout, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
// The other branches are set in the bare repository itself: a shallow push of several refs at once has
// receive-pack fail every ref after the first ("remote failed to report status").
for (const branch of rest) execFileSync("git", ["-C", bare, "update-ref", `refs/heads/${branch}`, head]);
return head;
}