Let gitea_create_repo create in an organisation, saying the forge's refusal, so novox repositories can be made through the tools (issue 1124)
mesh/merge-gate head 0d3f0fd3fc89 merged into trunk 7f77ce663a9e — pass: builds gitea → novox; no bus step; every machine composes with the change as it di…
mesh/repo-check head 0d3f0fd3fc89 merged into trunk 7f77ce663a9e — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery delivered

This commit is contained in:
2026-10-18 15:45:01 +02:00
parent 50fee22d0a
commit 0d3f0fd3fc
2 changed files with 16 additions and 4 deletions
+12 -2
View File
@@ -244,13 +244,23 @@ export class GiteaClient {
return all; return all;
} }
/** A repository, created under the tools' own user, or with `owner` in that organisation (novox/hq issue 1124).
* The forge's refusal to create in an organisation (403 not allowed, 404 no such organisation, 409 exists) is
* thrown with its status and its reason, naming the organisation. */
async createRepo(data: { async createRepo(data: {
name: string; name: string;
description?: string; description?: string;
private?: boolean; private?: boolean;
auto_init?: boolean; auto_init?: boolean;
}): Promise<GiteaRepo> { }, owner?: string): Promise<GiteaRepo> {
return GiteaClient.mapRepo(await this.request<any>("/user/repos", { method: "POST", body: JSON.stringify(data) })); const options = { method: "POST", body: JSON.stringify(data) };
if (owner === undefined) return GiteaClient.mapRepo(await this.request<any>("/user/repos", options));
const path = `/orgs/${pathSegment("organisation", owner)}/repos`;
try {
return GiteaClient.mapRepo(await this.request<any>(path, options));
} catch (e) {
throw new Error(`the forge did not create ${owner}/${data.name} in the organisation ${owner}: ${(e as Error).message}`);
}
} }
async deleteRepo(owner: string, repo: string): Promise<void> { async deleteRepo(owner: string, repo: string): Promise<void> {
+4 -2
View File
@@ -82,8 +82,10 @@ function allGiteaTools(gitea: GiteaClient, admin?: () => GiteaAdmin): ToolDefini
}, },
{ {
name: "gitea_create_repo", name: "gitea_create_repo",
description: "Create a repository owned by the authenticated user.", description: "Create a repository: with owner, in that organisation (the forge's refusal said with its status " +
"and reason); without owner, under the tools' own user.",
input: { input: {
owner: { type: "string", description: "an organisation to create the repository in (default: the tools' own user)" },
name: { type: "string", description: "the repository name" }, name: { type: "string", description: "the repository name" },
description: { type: "string", description: "an optional description" }, description: { type: "string", description: "an optional description" },
private: { type: "boolean", description: "private repo (default true)" }, private: { type: "boolean", description: "private repo (default true)" },
@@ -95,7 +97,7 @@ function allGiteaTools(gitea: GiteaClient, admin?: () => GiteaAdmin): ToolDefini
description: args.description ? String(args.description) : undefined, description: args.description ? String(args.description) : undefined,
private: args.private === undefined ? true : Boolean(args.private), private: args.private === undefined ? true : Boolean(args.private),
auto_init: args.auto_init === undefined ? true : Boolean(args.auto_init), auto_init: args.auto_init === undefined ? true : Boolean(args.auto_init),
}); }, args.owner === undefined ? undefined : String(args.owner));
return { repo }; return { repo };
}, },
}, },