- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/scripts/capacity-install-git-runtime.mjs?version=281&format=json
61 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 178, 1 version changed it
You're reading version 281. The newest is 318, and no version since then changed this file.
1import { execFileSync } from "node:child_process";
2import { createHash } from "node:crypto";
3import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4import { tmpdir } from "node:os";
5import { basename, dirname, join, resolve } from "node:path";
6import { fileURLToPath } from "node:url";
8const scripts = dirname(fileURLToPath(import.meta.url));
9const rootIndex = process.argv.indexOf("--root");
10if (rootIndex < 0 || !process.argv[rootIndex + 1])
11 throw Error("Pass --root with the exact isomorphic-git package directory");
12const root = resolve(process.argv[rootIndex + 1]);
13const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
14const original = {
15 "index.js": "66c20b7d890a6d48819f0be5f7bb1c5aab69937e6318ec912295c501028a5084",
16 "index.cjs": "b2142bba9e651fce83d6c1d266d32fc5eefa748544c452f9f22fada4e33dc367",
17};
18const expected = {
19 "index.js": "50ada141b506bff7cced797098f5ea70a6e40cda859884cc25b0dea985b10592",
20 "index.cjs": "3b8a78b7145330038cf56e057f7726004a78d0af9a55845b685cf1f65443bae0",
21};
22if (JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version !== "1.44.2")
23 throw Error("Unsupported Git version");
24const installed = Object.fromEntries(Object.keys(original).map((file) => [file, readFileSync(join(root, file))]));
25if (Object.entries(expected).every(([file, digest]) => hash(installed[file]) === digest)) {
26 console.log("Verified the complete Git capacity runtime patch.");
27 process.exit(0);
28}
29if (process.argv.includes("--check")) throw Error("Complete Git capacity runtime patch is absent or modified");
30for (const [file, digest] of Object.entries(original)) {
31 if (hash(installed[file]) !== digest) throw Error(`Unrecognized or partially patched Git bundle: ${file}`);
32}
33const temporary = mkdtempSync(join(tmpdir(), "abso-git-patch-"));
34if (dirname(resolve(temporary)) !== resolve(tmpdir()) || !basename(temporary).startsWith("abso-git-patch-"))
35 throw Error("Unexpected temporary cleanup path");
36try {
37 const staged = join(temporary, "capacity-git-dependency-sandbox/node_modules/isomorphic-git");
38 mkdirSync(staged, { recursive: true });
39 copyFileSync(join(root, "package.json"), join(staged, "package.json"));
40 for (const [file, bytes] of Object.entries(installed)) writeFileSync(join(staged, file), bytes);
41 copyFileSync(join(scripts, "capacity-git-bounded-fifo.mjs"), join(temporary, "capacity-git-bounded-fifo.mjs"));
42 for (const stage of ["push", "fetch", "sideband", "progress", "pump"]) {
43 execFileSync(process.execPath, [join(scripts, `capacity-patch-git-${stage}.mjs`)], {
44 cwd: temporary,
45 stdio: "pipe",
46 });
47 }
48 const outputs = Object.fromEntries(Object.keys(expected).map((file) => [file, readFileSync(join(staged, file))]));
49 for (const [file, digest] of Object.entries(expected)) {
50 if (hash(outputs[file]) !== digest) throw Error(`Unexpected complete Git patch: ${file}`);
51 }
52 // All stages and both final hashes pass before touching the installed package.
53 for (const [file, bytes] of Object.entries(outputs)) writeFileSync(join(root, file), bytes);
54 console.log("Installed and verified the complete Git capacity runtime patch.");
55} finally {
56 try {
57 rmSync(temporary, { recursive: true, force: true });
58 } catch {
59 console.warn("Could not remove the Git patch staging directory.");
60 }
61}