C1: the gate and the forge hold no branch name; the trunk is the asked branch, a default is the repository's
Builds: design 47 G §428, §507, A-93 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -17,12 +17,19 @@ const rules = [
|
||||
{ branch_name: "release", enable_push: false },
|
||||
];
|
||||
const seen: string[] = [];
|
||||
const opened: { base?: string }[] = [];
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
const path = (req.url ?? "").replace(/^\/api\/v1/, "");
|
||||
const as = req.headers.authorization === adminBasic ? "admin" : "tools";
|
||||
seen.push(`${req.method} ${path} as ${as}`);
|
||||
const send = (status: number, body: unknown) => { res.writeHead(status, { "Content-Type": "application/json" }); res.end(JSON.stringify(body)); };
|
||||
if (path === "/repos/novox/app") return send(200, { full_name: "novox/app", default_branch: "trunk" });
|
||||
if (req.method === "POST" && path === "/repos/novox/app/pulls") {
|
||||
let raw = "";
|
||||
req.on("data", (c) => (raw += c));
|
||||
return req.on("end", () => { opened.push(JSON.parse(raw)); send(201, { number: 7, title: "t", state: "open", html_url: "u" }); });
|
||||
}
|
||||
if (path.includes("/branch_protections")) {
|
||||
if (as !== "admin") return send(403, { message: "user should be an owner or a collaborator with admin write of a repository" });
|
||||
if (req.method === "GET") return send(200, rules);
|
||||
@@ -57,3 +64,10 @@ test("gitea_branch_protection_set still gets the forge's refusal, as the tools'
|
||||
);
|
||||
assert.ok(!seen.some((s) => /^(PATCH|POST|PUT|DELETE) .*branch_protections.* as admin$/.test(s)), seen.join("\n"));
|
||||
});
|
||||
|
||||
// Design 47 G §428: no part's code holds a branch's name; a pull request opened with no base goes to the repository's default branch.
|
||||
test("gitea_create_pull_request with no base opens against the repository's default branch, and a named base stays", async () => {
|
||||
await tool("gitea_create_pull_request").run({ owner: "novox", repo: "app", title: "t", head: "feat/x" });
|
||||
await tool("gitea_create_pull_request").run({ owner: "novox", repo: "app", title: "t", head: "feat/x", base: "release" });
|
||||
assert.deepEqual(opened.map((o) => o.base), ["trunk", "release"]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user