test: add bot check debug logs
This commit is contained in:
+30
-7
@@ -34,7 +34,8 @@ export async function getCommitMessageBySha(sha) {
|
||||
httpsAgent,
|
||||
});
|
||||
return resp.data?.message || '';
|
||||
} catch {
|
||||
} catch (e) {
|
||||
console.log(` ⚠️ bot-check: 讀取 commit sha=${sha} 失敗: ${e.message}`);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -49,17 +50,39 @@ export async function getBranchHeadCommitMessage(branch = PR_HEAD_BRANCH) {
|
||||
});
|
||||
const sha = resp.data?.commit?.id || resp.data?.commit?.sha || '';
|
||||
return await getCommitMessageBySha(sha);
|
||||
} catch {
|
||||
} catch (e) {
|
||||
console.log(` ⚠️ bot-check: 讀取 branch=${branch} head commit 失敗: ${e.message}`);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export async function shouldSkipBotCommit({ sha = PR_HEAD_SHA || process.env.GITHUB_SHA, branch = PR_HEAD_BRANCH } = {}) {
|
||||
const candidates = [
|
||||
await getCommitMessageBySha(sha),
|
||||
await getBranchHeadCommitMessage(branch),
|
||||
].filter(Boolean);
|
||||
return candidates.some(message => message.includes('[ai-review-bot]'));
|
||||
console.log(` 🔎 bot-check: start sha=${sha || 'empty'} branch=${branch || 'empty'}`);
|
||||
|
||||
const shaMessage = await getCommitMessageBySha(sha);
|
||||
if (sha) {
|
||||
console.log(` 🔎 bot-check: sha=${sha} message=${shaMessage ? 'found' : 'empty'}`);
|
||||
if (shaMessage.includes('[ai-review-bot]')) {
|
||||
console.log(' ✅ bot-check: matched commit sha marker');
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
console.log(' 🔎 bot-check: skip sha lookup because sha is empty');
|
||||
}
|
||||
|
||||
const branchMessage = await getBranchHeadCommitMessage(branch);
|
||||
if (branch) {
|
||||
console.log(` 🔎 bot-check: branch=${branch} head_message=${branchMessage ? 'found' : 'empty'}`);
|
||||
if (branchMessage.includes('[ai-review-bot]')) {
|
||||
console.log(' ✅ bot-check: matched branch head marker');
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
console.log(' 🔎 bot-check: skip branch lookup because branch is empty');
|
||||
}
|
||||
|
||||
console.log(' ℹ️ bot-check: no [ai-review-bot] marker found');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user