feat: adapt pullfrog for gitea + ollama
This commit is contained in:
+18
-5
@@ -12,20 +12,33 @@ export function AddLabelsTool(ctx: ToolContext) {
|
||||
return tool({
|
||||
name: "add_labels",
|
||||
description:
|
||||
"Add labels to a GitHub issue or pull request. Only use labels that already exist in the repository.",
|
||||
"Add labels to a Gitea issue or pull request. Only use labels that already exist in the repository.",
|
||||
parameters: AddLabelsParams,
|
||||
execute: execute(async ({ issue_number, labels }) => {
|
||||
const result = await ctx.octokit.rest.issues.addLabels({
|
||||
// Resolve label names to IDs (Gitea uses IDs, not names)
|
||||
const allLabels = await ctx.gitea.paginate(ctx.gitea.rest.issue.issueListLabels, {
|
||||
owner: ctx.repo.owner,
|
||||
repo: ctx.repo.name,
|
||||
issue_number,
|
||||
labels,
|
||||
});
|
||||
const labelIds = labels
|
||||
.map((name) => allLabels.find((l) => l.name === name)?.id)
|
||||
.filter((id): id is number => typeof id === "number");
|
||||
|
||||
if (labelIds.length === 0) {
|
||||
return { success: true, labels: [], message: "No matching labels found in repository" };
|
||||
}
|
||||
|
||||
const result = await ctx.gitea.rest.issue.issueAddLabel({
|
||||
owner: ctx.repo.owner,
|
||||
repo: ctx.repo.name,
|
||||
index: issue_number,
|
||||
body: { labels: labelIds },
|
||||
});
|
||||
log.info(`» added labels [${labels.join(", ")}] to issue #${issue_number}`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
labels: result.data.map((label) => label.name),
|
||||
labels: result.data.map((label) => label.name).filter(Boolean),
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user