announceHead with its mesh/merge-gate pending, the weighing of trunk and sibling moves (passPulls, trunksMoved, siblingMoves, GateWriter) and their files on disk, the pass's pull-passing half with its 60 s retry, and the 10-minute keep-main-rules step go. A pull request's new head is said as pull.updated from the forge's event alone; the seat's status writes through the client; pollRepos, pollMerged and readAllAtStart stay. Builds: design 47 H §764 (the forge module: the merge-check machinery, its poll and timer), §762; H-A-28, H-A-100 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
46 lines
2.1 KiB
TypeScript
46 lines
2.1 KiB
TypeScript
// The operator, 2026-10-23: "disable the gitea branch protection reset thing". keep-main-rules false (the default)
|
|
// writes nothing at the forge, true puts main's rule right as before.
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
import { keepMainRules } from "../dist/mainrules.js";
|
|
|
|
function env(body?: string): NodeJS.ProcessEnv {
|
|
if (body === undefined) return {};
|
|
const f = join(mkdtempSync(join(tmpdir(), "gitea-keep-")), "config.json");
|
|
writeFileSync(f, body);
|
|
return { MESH_GITEA_CONFIG_FILE: f };
|
|
}
|
|
|
|
test("the setting is false unless the config says true", () => {
|
|
assert.equal(keepMainRules(env()), false);
|
|
assert.equal(keepMainRules(env("{}")), false);
|
|
assert.equal(keepMainRules(env('{"keep-main-rules":false}')), false);
|
|
assert.equal(keepMainRules(env("not json")), false);
|
|
assert.equal(keepMainRules(env('{"keep-main-rules":true}')), true);
|
|
});
|
|
|
|
test("a token mint's account setup writes no protection while keep-main-rules is false, and does when true", async () => {
|
|
const { setUpToolsAccount } = await import("../dist/tools-account.js");
|
|
for (const [keep, want] of [[false, 0], [true, 1]] as const) {
|
|
let merges = 0;
|
|
const forge = {
|
|
ensureUser: async () => {}, ensureTeamWith: async () => 1, addUserToTeam: async () => {},
|
|
ensureMainMerges: async () => { merges++; return []; },
|
|
};
|
|
await setUpToolsAccount(forge, "mesh-tools", () => "pw", keep);
|
|
assert.equal(merges, want);
|
|
}
|
|
// The default comes from the setting, which is false when the config does not say true.
|
|
let merges = 0;
|
|
const saved = process.env.MESH_GITEA_CONFIG_FILE;
|
|
delete process.env.MESH_GITEA_CONFIG_FILE;
|
|
try {
|
|
await setUpToolsAccount({ ensureUser: async () => {}, ensureTeamWith: async () => 1, addUserToTeam: async () => {}, ensureMainMerges: async () => { merges++; return []; } }, "mesh-tools", () => "pw");
|
|
} finally { if (saved !== undefined) process.env.MESH_GITEA_CONFIG_FILE = saved; }
|
|
assert.equal(merges, 0);
|
|
});
|