feat: 嚴重問題改用 Gitea 行內 review comment 標註檔案行數
每個新的嚴重問題改以行內 review comment 標註在問題所在的檔案與行數上, 留言內容為等級/審查員/建議;無法解析出行號(未標行號或一次列出多個 檔案),或行內留言失敗(該行不在 diff 範圍)時,降級為原本的一般 PR comment。 - gitea.js:新增 postPullReviewComment,呼叫 pull reviews API,以 new_position 對應新版檔案行號、commit_id 帶 PR_HEAD_SHA - comments.js:新增 parseLocation(支援 file:19 / file:70-82,取起始行)與 行內留言內容組裝;postNewCriticalComments 先試行內、失敗降級,deps 可注入 - 補 11 個測試(API payload、parseLocation 各情境、行內成功與兩種降級路徑) - README 更新流程第 7 步說明 app/ 測試 123 pass。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -127,3 +127,22 @@ export async function postComment(body) {
|
||||
);
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在 PR 指定檔案的指定行數發布行內 review comment(標註程式碼位置)。
|
||||
* 透過 Gitea 的 pull reviews API,以 new_position 對應新版檔案的行號。
|
||||
* 若該行不在 diff 範圍內,Gitea 會回傳錯誤,由呼叫端決定是否降級為一般 comment。
|
||||
*/
|
||||
export async function postPullReviewComment({ path: filePath, line, body }) {
|
||||
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 }],
|
||||
},
|
||||
{ headers: headers(GITEA_COMMENT_TOKEN || GITEA_TOKEN), timeout: 30000, httpsAgent },
|
||||
);
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user