fix: get diffs properly
This commit is contained in:
+9
-9
@@ -11,6 +11,7 @@ import {
|
||||
import { fixDoubleEscapedString } from "../utils/fixDoubleEscapedString.ts";
|
||||
import type { ChangedFileWithPatch } from "../utils/gitea.ts";
|
||||
import { retry } from "../utils/retry.ts";
|
||||
import { parseDiffToFiles } from "./checkout.ts";
|
||||
import { deleteProgressComment } from "./comment.ts";
|
||||
import type { ToolContext } from "./server.ts";
|
||||
import { execute, tool } from "./shared.ts";
|
||||
@@ -62,17 +63,16 @@ export async function buildCommentableMap(
|
||||
const currentSha = ctx.toolState.checkoutSha;
|
||||
if (cached && cachedFor === pullNumber && cachedSha && cachedSha === currentSha) return cached;
|
||||
|
||||
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 r = await ctx.gitea.rest.repository.repoDownloadPullDiffOrPatch({
|
||||
owner: ctx.repo.owner,
|
||||
repo: ctx.repo.name,
|
||||
index: pullNumber,
|
||||
diffType: "diff",
|
||||
});
|
||||
const files = parseDiffToFiles(r.data);
|
||||
const map = new Map<string, CommentableLines>();
|
||||
for (const file of files) {
|
||||
if (file.filename) {
|
||||
map.set(file.filename, commentableLinesForFile(file.patch));
|
||||
}
|
||||
if (file.filename) map.set(file.filename, commentableLinesForFile(file.patch));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user