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:
2026-11-12 22:18:25 +01:00
parent a6ce8dcbd6
commit 0aa5d6637c
6 changed files with 47 additions and 35 deletions
+10 -4
View File
@@ -93,6 +93,12 @@ export function getGiteaTools(gitea: GiteaClient, admin?: () => GiteaAdmin): Too
// A merge, a status, a comment, a delivery's view and its note are the seat git's acts (seat.ts), asked by the forge
// bridge alone: no tool of the module's own does them (novox/hq design 47 *The seat git*).
function allGiteaTools(gitea: GiteaClient, admin: (() => GiteaAdmin) | undefined): ToolDefinition[] {
// A branch no caller named is the repository's default branch, as the forge says it; no part's code holds one (§428).
const defaultBranchOf = async (owner: string, repo: string): Promise<string> => {
const found = String((await gitea.getRepo(owner, repo)).default_branch ?? "");
if (!found) throw new Error(`the forge names no default branch of ${owner}/${repo}: name the branch`);
return found;
};
return [
// ---- Repositories ----
{
@@ -269,14 +275,14 @@ function allGiteaTools(gitea: GiteaClient, admin: (() => GiteaAdmin) | undefined
title: { type: "string", description: "the PR title" },
body: { type: "string", description: "the PR body (markdown)" },
head: { type: "string", description: "the source branch" },
base: { type: "string", description: "the target branch (default main)" },
base: { type: "string", description: "the target branch (default: the repository's default branch)" },
},
run: async (args) => ({
pull: await gitea.createPullRequest(String(args.owner), String(args.repo), {
title: String(args.title),
body: args.body ? String(args.body) : undefined,
head: String(args.head),
base: args.base ? String(args.base) : "main",
base: args.base ? String(args.base) : await defaultBranchOf(String(args.owner), String(args.repo)),
}),
}),
},
@@ -679,7 +685,7 @@ function allGiteaTools(gitea: GiteaClient, admin: (() => GiteaAdmin) | undefined
repo: { type: "string", description: "the repository name" },
number: { type: "number", description: "a pull request's number: its head is read, and its base's protection" },
sha: { type: "string", description: "a commit, or the start of one, instead of a pull request" },
base: { type: "string", description: "with sha: the branch whose protection is read (default main)" },
base: { type: "string", description: "with sha: the branch whose protection is read (default: the repository's default branch)" },
},
run: async (args) => {
const owner = String(args.owner ?? "").trim(), repo = String(args.repo ?? "").trim();
@@ -702,7 +708,7 @@ function allGiteaTools(gitea: GiteaClient, admin: (() => GiteaAdmin) | undefined
if (!ref) throw new Error("name a pull request's number or a commit");
const combined = await gitea.combinedStatus(owner, repo, ref);
const statuses = newestByContext(combined.statuses);
base = base || "main";
base = base || (await defaultBranchOf(owner, repo));
let rule: BranchProtection | null = null, unreadable: string | undefined;
try {
rule = await gitea.appliedProtection(owner, repo, base);