feat(ai-review comment): 集中更新單一審查留言
This commit is contained in:
+7
-5
@@ -55,28 +55,30 @@ export function saveFindings(workspace, findings, mirrorDir = null) {
|
||||
/**
|
||||
* 發布所有舊問題 comment(一次發布,依等級排序)
|
||||
*/
|
||||
export async function postOldFindingsComment(findings) {
|
||||
export async function postOldFindingsComment(findings, deps = {}) {
|
||||
const { postIssue = postComment } = deps;
|
||||
const old = findings.filter(f => !f.is_new);
|
||||
if (old.length === 0) {
|
||||
line('無舊問題,跳過');
|
||||
return;
|
||||
}
|
||||
const body = `## 📋 舊有未解決問題(${old.length} 筆)\n\n${buildTable(old)}`;
|
||||
await postComment(body);
|
||||
await postIssue(body);
|
||||
ok(`舊問題 comment 發布 (${old.length} 筆)`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 發布新問題中非 critical 的 comment(一次發布)
|
||||
*/
|
||||
export async function postNewNonCriticalComment(findings) {
|
||||
export async function postNewNonCriticalComment(findings, deps = {}) {
|
||||
const { postIssue = postComment } = deps;
|
||||
const items = findings.filter(f => f.is_new && f.level !== 'critical');
|
||||
if (items.length === 0) {
|
||||
line('無新的非嚴重問題,跳過');
|
||||
return;
|
||||
}
|
||||
const body = `## 🔍 新發現問題(${items.length} 筆)\n\n${buildTable(items)}`;
|
||||
await postComment(body);
|
||||
await postIssue(body);
|
||||
ok(`新問題(非嚴重)comment 發布 (${items.length} 筆)`);
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ export async function postNewCriticalComments(findings, deps = {}) {
|
||||
}
|
||||
for (const f of criticals) {
|
||||
const loc = parseLocation(f.location);
|
||||
if (loc) {
|
||||
if (postInline && loc) {
|
||||
try {
|
||||
await postInline({ path: loc.file, line: loc.line, body: inlineCommentBody(f) });
|
||||
ok(`嚴重問題 行內 comment 發布: [${f.role}] ${loc.file}:${loc.line}`);
|
||||
|
||||
Reference in New Issue
Block a user