feat: report ai review commit status
This commit is contained in:
@@ -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 精確比對前綴。
|
||||
|
||||
Reference in New Issue
Block a user