fix: issues with pagination not resolving correct url templates
This commit is contained in:
+22
-24
@@ -62,11 +62,11 @@ export async function buildCommentableMap(
|
||||
const currentSha = ctx.toolState.checkoutSha;
|
||||
if (cached && cachedFor === pullNumber && cachedSha && cachedSha === currentSha) return cached;
|
||||
|
||||
const files = (await ctx.gitea.paginate(ctx.gitea.rest.repository.repoGetPullRequestFiles, {
|
||||
owner: ctx.repo.owner,
|
||||
repo: ctx.repo.name,
|
||||
index: pullNumber,
|
||||
})) as ChangedFileWithPatch[];
|
||||
const r = await ctx.gitea.request(
|
||||
"GET /repos/{owner}/{repo}/pulls/{index}/files",
|
||||
{ owner: ctx.repo.owner, repo: ctx.repo.name, index: pullNumber, limit: 50 }
|
||||
);
|
||||
const files = r.data as ChangedFileWithPatch[];
|
||||
|
||||
const map = new Map<string, CommentableLines>();
|
||||
for (const file of files) {
|
||||
@@ -244,12 +244,11 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
|
||||
let effectiveCommitId = commit_id;
|
||||
if (!effectiveCommitId) {
|
||||
try {
|
||||
const pr = await ctx.gitea.rest.repository.repoGetPullRequest({
|
||||
owner: ctx.repo.owner,
|
||||
repo: ctx.repo.name,
|
||||
index: pull_number,
|
||||
});
|
||||
latestHeadSha = pr.data.head?.sha;
|
||||
const pr = await ctx.gitea.request(
|
||||
"GET /repos/{owner}/{repo}/pulls/{index}",
|
||||
{ owner: ctx.repo.owner, repo: ctx.repo.name, index: pull_number }
|
||||
);
|
||||
latestHeadSha = (pr.data as { head?: { sha?: string } }).head?.sha;
|
||||
effectiveCommitId = ctx.toolState.checkoutSha ?? latestHeadSha;
|
||||
} catch {
|
||||
effectiveCommitId = ctx.toolState.checkoutSha;
|
||||
@@ -301,18 +300,16 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
|
||||
const footer = buildShockbotFooter({ model: ctx.toolState.model });
|
||||
const fullBody = body ? `${body}${footer}` : footer.trimStart();
|
||||
|
||||
const result = await retry<Awaited<ReturnType<typeof ctx.gitea.rest.repository.repoCreatePullReview>>>(
|
||||
const result = await retry(
|
||||
() =>
|
||||
ctx.gitea.rest.repository.repoCreatePullReview({
|
||||
ctx.gitea.request("POST /repos/{owner}/{repo}/pulls/{index}/reviews", {
|
||||
owner: ctx.repo.owner,
|
||||
repo: ctx.repo.name,
|
||||
index: pull_number,
|
||||
body: {
|
||||
body: fullBody,
|
||||
commit_id: effectiveCommitId,
|
||||
event,
|
||||
comments: sdkComments,
|
||||
},
|
||||
body: fullBody,
|
||||
commit_id: effectiveCommitId,
|
||||
event,
|
||||
comments: sdkComments,
|
||||
}),
|
||||
{
|
||||
delaysMs: [1_000, 3_000],
|
||||
@@ -321,7 +318,8 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
|
||||
}
|
||||
);
|
||||
|
||||
const reviewId = result.data.id!;
|
||||
const reviewData = result.data as { id?: number; html_url?: string; state?: string };
|
||||
const reviewId = reviewData.id!;
|
||||
log.info(`» created review ${reviewId} on pull request #${pull_number}`);
|
||||
|
||||
ctx.toolState.review = {
|
||||
@@ -344,8 +342,8 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
|
||||
return {
|
||||
success: true,
|
||||
reviewId,
|
||||
html_url: result.data.html_url,
|
||||
state: result.data.state,
|
||||
html_url: reviewData.html_url,
|
||||
state: reviewData.state,
|
||||
droppedComments: droppedComments.length > 0 ? droppedComments : undefined,
|
||||
newCommits: {
|
||||
from: fromSha,
|
||||
@@ -358,8 +356,8 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
|
||||
return {
|
||||
success: true,
|
||||
reviewId,
|
||||
html_url: result.data.html_url,
|
||||
state: result.data.state,
|
||||
html_url: reviewData.html_url,
|
||||
state: reviewData.state,
|
||||
droppedComments: droppedComments.length > 0 ? droppedComments : undefined,
|
||||
};
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user