feat(建問題模式): 無問題時靜默通過,不在 PR 留任何審查留言
This commit is contained in:
+6
-6
@@ -130,7 +130,7 @@ function commitFindings({ cwd, ctx, files, result }) {
|
|||||||
* 10. 警告+建議彙整為單一表格留言;
|
* 10. 警告+建議彙整為單一表格留言;
|
||||||
* 建問題模式(input: create-issue):不執行步驟 2、不觸碰 PR 既有留言;步驟 3~10 的所有留言
|
* 建問題模式(input: create-issue):不執行步驟 2、不觸碰 PR 既有留言;步驟 3~10 的所有留言
|
||||||
* 改發到追蹤 issue(工具/diff/角色留言先暫存,確定有保留問題後才建立 issue 並一次寫入,
|
* 改發到追蹤 issue(工具/diff/角色留言先暫存,確定有保留問題後才建立 issue 並一次寫入,
|
||||||
* 嚴重問題與警告+建議亦發到該 issue);無保留問題則不建 issue、僅在 PR 留審查通過提示;
|
* 嚴重問題與警告+建議亦發到該 issue);無保留問題或無可審查變更則不建 issue、PR 也完全不留言(靜默通過);
|
||||||
* 收束時依保留問題補掛 issue 標籤,並在 PR 回貼 issue 連結形成雙向關聯;
|
* 收束時依保留問題補掛 issue 標籤,並在 PR 回貼 issue 連結形成雙向關聯;
|
||||||
* 收尾:組 filesToCommit —— 一般模式 commit findings 檔(+有變更的 exclusions.json)、
|
* 收尾:組 filesToCommit —— 一般模式 commit findings 檔(+有變更的 exclusions.json)、
|
||||||
* 建問題模式只 commit exclusions.json、無檔案可 commit 時略過;
|
* 建問題模式只 commit exclusions.json、無檔案可 commit 時略過;
|
||||||
@@ -253,10 +253,10 @@ async function main() {
|
|||||||
log('步驟4', 'INF', `變更檔案 ${allFiles.length} 個,套用 .reviewignore 後送審 ${files.length} 個(排除 ${ignoredCount} 個)。`);
|
log('步驟4', 'INF', `變更檔案 ${allFiles.length} 個,套用 .reviewignore 後送審 ${files.length} 個(排除 ${ignoredCount} 個)。`);
|
||||||
|
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
// 沒有可審查的變更:告知、保存空 findings、以 success 收場。
|
// 沒有可審查的變更:保存空 findings、以 success 收場。
|
||||||
// 建問題模式無問題可追蹤 → 不建 issue,直接在 PR 告知(暫存的情境留言捨棄)。
|
// 一般模式在 PR 留言告知;建問題模式靜默通過(不建 issue、PR 也不留言,暫存的情境留言捨棄)。
|
||||||
if (ctx.createIssue) {
|
if (ctx.createIssue) {
|
||||||
await gitea.createIssueComment(ctx, templates.nothingToReviewComment(ignoredCount));
|
log('步驟4', 'INF', '建問題模式且無可審查變更:靜默通過(不建 issue、PR 不留言)。');
|
||||||
} else {
|
} else {
|
||||||
await postComment(templates.nothingToReviewComment(ignoredCount));
|
await postComment(templates.nothingToReviewComment(ignoredCount));
|
||||||
}
|
}
|
||||||
@@ -306,8 +306,8 @@ async function main() {
|
|||||||
if (kept.length > 0) {
|
if (kept.length > 0) {
|
||||||
await ensureIssueCreated();
|
await ensureIssueCreated();
|
||||||
} else {
|
} else {
|
||||||
log('建問題', 'INF', '沒有保留的問題,略過建立 issue,於 PR 留審查通過提示。');
|
// 無保留問題 → 不建 issue、PR 也不留言(靜默通過,暫存的情境留言捨棄)。
|
||||||
await gitea.createIssueComment(ctx, templates.noFindingsComment());
|
log('建問題', 'INF', '沒有保留的問題:靜默通過(不建 issue、PR 不留言)。');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -407,24 +407,6 @@ function issueLinkComment({ issueNumber, issueUrl, severeCount, otherCount }) {
|
|||||||
本次審查結果已彙整到 issue [#${issueNumber}](${issueUrl})(🔴 嚴重 ${severeCount} 條、🟠🔵 警告+建議 ${otherCount} 條),請至該問題追蹤與討論。`;
|
本次審查結果已彙整到 issue [#${issueNumber}](${issueUrl})(🔴 嚴重 ${severeCount} 條、🟠🔵 警告+建議 ${otherCount} 條),請至該問題追蹤與討論。`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 產生「已審查但無需保留問題」時,回貼到「PR」的審查通過留言。
|
|
||||||
*
|
|
||||||
* 建問題模式下,若防守方裁決後沒有任何保留問題(不值得為此開 issue),
|
|
||||||
* 以本留言在 PR 上告知審查通過,取代原本會發到 issue 的問題內容。
|
|
||||||
*
|
|
||||||
* @returns {string} 完整留言 Markdown 字串(含 MARK 隱藏標記)。
|
|
||||||
* @remarks
|
|
||||||
* 使用情境:建問題模式下 `main()`(src/index.js)於防守方裁決後
|
|
||||||
* `kept.length === 0` 時呼叫;此情況不建立 issue,僅在 PR 留下本則通過提示。
|
|
||||||
*/
|
|
||||||
function noFindingsComment() {
|
|
||||||
return `${MARK}
|
|
||||||
## ✅ AI Code Review|審查通過
|
|
||||||
|
|
||||||
本次 AI Code Review 未發現需保留的問題,視為審查通過。`;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
MARK,
|
MARK,
|
||||||
OUTDATED_PREFIX,
|
OUTDATED_PREFIX,
|
||||||
@@ -440,5 +422,4 @@ module.exports = {
|
|||||||
issueFindingComment,
|
issueFindingComment,
|
||||||
nothingToReviewComment,
|
nothingToReviewComment,
|
||||||
issueLinkComment,
|
issueLinkComment,
|
||||||
noFindingsComment,
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user