feat: report ai review commit status

This commit is contained in:
2026-05-15 14:39:15 +00:00
parent 93c3d0ca66
commit 4fd9a22aa0
4 changed files with 63 additions and 4 deletions
+18
View File
@@ -95,6 +95,24 @@ export async function shouldSkipBotCommit({ sha = PR_HEAD_SHA || process.env.GIT
return false;
}
export async function setCommitStatus(sha, state, description, context = 'ai-review/critical', targetUrl = '') {
if (!sha) throw new Error('commit sha is required for status update');
const payload = {
state,
context,
description,
};
if (targetUrl) payload.target_url = targetUrl;
const resp = await axios.post(api(`/repos/${GITEA_REPOSITORY}/statuses/${encodeURIComponent(sha)}`), payload, {
headers: headers(),
timeout: 30000,
httpsAgent,
});
console.log(` ✅ status: sha=${sha} state=${state} context=${context} description=${description}`);
return resp.data;
}
/**
* 過濾 diff 內容,移除路徑符合 excludePrefixes 的區塊。
* 每個區塊以 "diff --git a/<prefix>" 開頭判斷,使用 startsWith 精確比對前綴。