diff --git a/modules/gitea/seat.ts b/modules/gitea/seat.ts index 8cd08bd95..1c0c97124 100644 --- a/modules/gitea/seat.ts +++ b/modules/gitea/seat.ts @@ -152,7 +152,10 @@ export function seatTools(gitea: GiteaClient, deps: SeatDeps): ToolDefinition[] verb(GIT_VERBS.branch, "The seat git's branch: a branch's head, and whether a protection rule refuses a direct push and admits only merges.", async (args): Promise => { const { owner, repo, full } = repositoryOf(args.repository); - const branch = String(args.branch ?? ""); + // No branch named is the repository's default branch, read from the forge, as the verb file reads it (A-399). + let branch = String(args.branch ?? ""); + if (branch === "") branch = String((await gitea.getRepo(owner, repo)).default_branch ?? ""); + if (branch === "") throw new Error(`the forge names no default branch of ${full}`); // The head first: a branch the forge does not hold is its 404, the kind not-found, never an unprotected branch. const head = await gitea.branchHead(owner, repo, branch); return { repository: full, branch, head, protected: pushRefused(await gitea.appliedProtection(owner, repo, branch)) };