fix(Step9): 優先用 Gitea 狀態阻擋合併
This commit is contained in:
@@ -118,6 +118,23 @@ export async function postComment(body) {
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
export async function blockPRMergeWithStatus({ sha = PR_HEAD_SHA || process.env.GITHUB_SHA, criticalCount = 0 } = {}) {
|
||||
if (!sha) throw new Error('缺少 PR head commit sha,無法建立 Gitea status');
|
||||
|
||||
const countText = criticalCount > 0 ? `${criticalCount} 個` : '';
|
||||
const resp = await axios.post(
|
||||
api(`/repos/${GITEA_REPOSITORY}/statuses/${encodeURIComponent(sha)}`),
|
||||
{
|
||||
state: 'failure',
|
||||
target_url: `${GITEA_SERVER_URL.replace(/\/$/, '')}/${GITEA_REPOSITORY}/pulls/${PR_NUMBER}`,
|
||||
description: `AI Code Review 發現${countText}嚴重問題,請修復後再合併。`,
|
||||
context: 'ai-code-review/critical',
|
||||
},
|
||||
{ headers: headers(), timeout: 30000, httpsAgent },
|
||||
);
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在 PR 指定檔案的指定行數發布行內 review comment(標註程式碼位置)。
|
||||
* 透過 Gitea 的 pull reviews API,以 new_position 對應新版檔案的行號。
|
||||
|
||||
Reference in New Issue
Block a user