Verdict words
Check / deno (pull_request) Successful in 34s

This commit is contained in:
2026-09-14 02:17:42 +09:00
parent 0d109ebec8
commit d1eaa7dbe0
2 changed files with 20 additions and 18 deletions
+9 -8
View File
@@ -62,12 +62,12 @@ async function postComment(body: string): Promise<void> {
// 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.
// the verdict, matched whole; anything unexpected only comments, never
// approves. The mark in front is added here, so it is never part of the match.
const REVIEW_PATH = `${await Deno.makeTempDir()}/review.md`;
const VERDICTS: Record<string, string> = {
Yes: "APPROVED",
No: "REQUEST_CHANGES",
"With fixes": "REQUEST_CHANGES",
const VERDICTS: Record<string, [event: string, mark: string]> = {
Approved: ["APPROVED", "✅"],
"Changes requested": ["REQUEST_CHANGES", "🛑"],
};
async function postResult(body: string): Promise<void> {
@@ -75,10 +75,11 @@ async function postResult(body: string): Promise<void> {
const review = await Deno.readTextFile(REVIEW_PATH).catch(() => {
throw new Error(`no review was written to ${REVIEW_PATH}`);
});
const [verdict] = review.split("\n", 1);
const [verdict, ...rest] = review.split("\n");
const [event, mark] = VERDICTS[verdict.trim()] ?? ["COMMENT", "💬"];
await gitea(REVIEWER_TOKEN, `repos/${REPO}/pulls/${INDEX}/reviews`, {
body: stripAnsi(review),
event: VERDICTS[verdict.trim()] ?? "COMMENT",
body: stripAnsi([`${mark} ${verdict.trim()}`, ...rest].join("\n")),
event,
});
}