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
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:
+12
-2
@@ -244,13 +244,23 @@ export class GiteaClient {
|
||||
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: {
|
||||
name: string;
|
||||
description?: string;
|
||||
private?: boolean;
|
||||
auto_init?: boolean;
|
||||
}): Promise<GiteaRepo> {
|
||||
return GiteaClient.mapRepo(await this.request<any>("/user/repos", { method: "POST", body: JSON.stringify(data) }));
|
||||
}, owner?: string): Promise<GiteaRepo> {
|
||||
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> {
|
||||
|
||||
@@ -82,8 +82,10 @@ function allGiteaTools(gitea: GiteaClient, admin?: () => GiteaAdmin): ToolDefini
|
||||
},
|
||||
{
|
||||
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: {
|
||||
owner: { type: "string", description: "an organisation to create the repository in (default: the tools' own user)" },
|
||||
name: { type: "string", description: "the repository name" },
|
||||
description: { type: "string", description: "an optional description" },
|
||||
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,
|
||||
private: args.private === undefined ? true : Boolean(args.private),
|
||||
auto_init: args.auto_init === undefined ? true : Boolean(args.auto_init),
|
||||
});
|
||||
}, args.owner === undefined ? undefined : String(args.owner));
|
||||
return { repo };
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user