fix: issues with pagination not resolving correct url templates

This commit is contained in:
2026-05-31 01:43:42 -05:00
parent 2aca1a3aa3
commit 0438688e32
14 changed files with 287 additions and 467 deletions
+26 -37
View File
@@ -1,6 +1,5 @@
/**
* Single source of truth for reading, updating, deleting, and creating "progress comments"
* the Gitea comments shockbot uses to surface a run's status.
* Single source of truth for reading, updating, deleting, and creating "progress comments".
*/
import type { Gitea } from "./gitea.ts";
@@ -27,16 +26,22 @@ interface ApiCtx {
repo: string;
}
interface GiteaComment {
id: number;
body?: string | null;
html_url?: string;
node_id?: string;
}
export async function getProgressComment(
ctx: ApiCtx,
comment: ProgressComment
): Promise<{ id: number; body: string | undefined; html_url: string }> {
const result = await ctx.gitea.rest.issue.issueGetComment({
owner: ctx.owner,
repo: ctx.repo,
id: comment.id,
const r = await ctx.gitea.request("GET /repos/{owner}/{repo}/issues/comments/{id}", {
owner: ctx.owner, repo: ctx.repo, id: comment.id,
});
return { id: result.data.id!, body: result.data.body ?? undefined, html_url: result.data.html_url! };
const data = r.data as GiteaComment;
return { id: data.id, body: data.body ?? undefined, html_url: data.html_url ?? "" };
}
export async function updateProgressComment(
@@ -44,28 +49,16 @@ export async function updateProgressComment(
comment: ProgressComment,
body: string
): Promise<{ id: number; body: string | undefined; html_url: string; node_id: string | undefined }> {
const result = await ctx.gitea.rest.issue.issueEditComment({
owner: ctx.owner,
repo: ctx.repo,
id: comment.id,
body: { body },
const r = await ctx.gitea.request("PATCH /repos/{owner}/{repo}/issues/comments/{id}", {
owner: ctx.owner, repo: ctx.repo, id: comment.id, body,
});
return {
id: result.data.id!,
body: result.data.body ?? undefined,
html_url: result.data.html_url!,
node_id: undefined,
};
const data = r.data as GiteaComment;
return { id: data.id, body: data.body ?? undefined, html_url: data.html_url ?? "", node_id: undefined };
}
export async function deleteProgressCommentApi(
ctx: ApiCtx,
comment: ProgressComment
): Promise<void> {
await ctx.gitea.rest.issue.issueDeleteComment({
owner: ctx.owner,
repo: ctx.repo,
id: comment.id,
export async function deleteProgressCommentApi(ctx: ApiCtx, comment: ProgressComment): Promise<void> {
await ctx.gitea.request("DELETE /repos/{owner}/{repo}/issues/comments/{id}", {
owner: ctx.owner, repo: ctx.repo, id: comment.id,
});
}
@@ -84,18 +77,14 @@ export async function createLeapingProgressComment(
target: CreateProgressCommentTarget,
body: string
): Promise<CreatedProgressComment> {
const issueNumber =
target.kind === "issue" ? target.issueNumber : target.pullNumber;
const result = await ctx.gitea.rest.issue.issueCreateComment({
owner: ctx.owner,
repo: ctx.repo,
index: issueNumber,
body: { body },
const issueNumber = target.kind === "issue" ? target.issueNumber : target.pullNumber;
const r = await ctx.gitea.request("POST /repos/{owner}/{repo}/issues/{index}/comments", {
owner: ctx.owner, repo: ctx.repo, index: issueNumber, body,
});
const data = r.data as GiteaComment;
return {
comment: { id: result.data.id!, type: "issue" },
body: result.data.body ?? undefined,
html_url: result.data.html_url!,
comment: { id: data.id, type: "issue" },
body: data.body ?? undefined,
html_url: data.html_url ?? "",
};
}