feat(review 發布): 將 AI 審查結果集中到同一筆 Pull Review

This commit is contained in:
2026-06-22 09:41:09 +00:00
parent 1b3c5a7aec
commit 1477822f4b
3 changed files with 88 additions and 21 deletions
+17 -7
View File
@@ -119,20 +119,30 @@ export async function postComment(body) {
}
/**
* 在 PR 指定檔案的指定行數發布行內 review comment(標註程式碼位置)
* 透過 Gitea 的 pull reviews API,以 new_position 對應新版檔案的行號。
* 若該行不在 diff 範圍內,Gitea 會回傳錯誤,由呼叫端決定是否降級為一般 comment。
* 建立一筆 Pull Review。body 會成為 review 主內容,comments 會成為同一筆 review 底下的行內 comments
*/
export async function postPullReviewComment({ path: filePath, line, body }) {
export async function createPullReview({ body, comments = [], event = 'COMMENT' }) {
const resp = await axios.post(
api(`/repos/${GITEA_REPOSITORY}/pulls/${PR_NUMBER}/reviews`),
{
commit_id: PR_HEAD_SHA || undefined,
event: 'COMMENT',
body: '',
comments: [{ path: filePath, body, new_position: line }],
event,
body,
comments,
},
{ headers: headers(GITEA_COMMENT_TOKEN || GITEA_TOKEN), timeout: 30000, httpsAgent },
);
return resp.data;
}
/**
* 在 PR 指定檔案的指定行數發布行內 review comment(標註程式碼位置)。
* 透過 Gitea 的 pull reviews API,以 new_position 對應新版檔案的行號。
* 若該行不在 diff 範圍內,Gitea 會回傳錯誤,由呼叫端決定是否降級為一般 comment。
*/
export async function postPullReviewComment({ path: filePath, line, body }) {
return createPullReview({
body: '',
comments: [{ path: filePath, body, new_position: line }],
});
}