Review file
Check / deno (pull_request) Successful in 32s

This commit is contained in:
2026-09-14 01:53:24 +09:00
parent a2bc4c9541
commit c8f325e048
2 changed files with 23 additions and 19 deletions
+11 -5
View File
@@ -59,9 +59,11 @@ async function postComment(body: string): Promise<void> {
});
}
// A pull request event is a review request, so the response becomes a review.
// Its first line is the verdict; anything unexpected only comments, never
// approves.
// A pull request event is a review request, so the review is posted instead
// of the response. It comes through a file, because a final chat message picks
// up narration while a file's first line is written on purpose. That line is
// the verdict; anything unexpected only comments, never approves.
const REVIEW_PATH = `${await Deno.makeTempDir()}/review.md`;
const VERDICTS: Record<string, string> = {
Yes: "APPROVED",
No: "REQUEST_CHANGES",
@@ -70,9 +72,12 @@ const VERDICTS: Record<string, string> = {
async function postResult(body: string): Promise<void> {
if (EVENT !== "pull_request") return postComment(body);
const [verdict] = body.split("\n", 1);
const review = await Deno.readTextFile(REVIEW_PATH).catch(() => {
throw new Error(`no review was written to ${REVIEW_PATH}`);
});
const [verdict] = review.split("\n", 1);
await gitea(REVIEWER_TOKEN, `repos/${REPO}/pulls/${INDEX}/reviews`, {
body: stripAnsi(body),
body: stripAnsi(review),
event: VERDICTS[verdict.trim()] ?? "COMMENT",
});
}
@@ -118,6 +123,7 @@ async function renderPrompt(): Promise<string> {
GITEA_API_URL: API,
GITEA_REPOSITORY: REPO,
ISSUE_INDEX: INDEX,
REVIEW_PATH,
};
const template = await Deno.readTextFile(
new URL("prompt.md", import.meta.url),