fix(review publish): 降級處理 Gitea review 批次發布失敗

This commit is contained in:
2026-06-25 15:26:09 +00:00
parent afec5a9387
commit 8272166fde
2 changed files with 46 additions and 1 deletions
+20 -1
View File
@@ -116,6 +116,8 @@ function toReviewComment(f) {
export async function postFindingsReview(findings, deps = {}) {
const {
postReview = postPullReview,
postInline = postPullReviewComment,
postIssue = postComment,
summaryFindings = findings,
commentFindings = findings,
usageSection = '',
@@ -123,7 +125,24 @@ export async function postFindingsReview(findings, deps = {}) {
const sortedComments = [...commentFindings].sort(bySeverity);
const comments = sortedComments.filter(f => f.is_new !== false).map(toReviewComment).filter(Boolean);
const body = buildReviewSummary(summaryFindings, usageSection);
await postReview({ body, comments });
try {
await postReview({ body, comments });
} catch (e) {
warn(`整批 review 發布失敗,改用 summary + 逐筆行內 comment: ${e.message}`);
try {
await postReview({ body, comments: [] });
} catch (summaryErr) {
warn(`review summary 發布失敗,改用一般 comment: ${summaryErr.message}`);
await postIssue(body);
}
for (const comment of comments) {
try {
await postInline({ path: comment.path, line: comment.new_position, body: comment.body });
} catch (commentErr) {
warn(`行內 review comment 發布失敗(略過): ${comment.path}:${comment.new_position} error=${commentErr.message}`);
}
}
}
ok(`review 發布: summary=${summaryFindings.length} total=${sortedComments.length} commentable=${comments.length}`);
line(`review summary 統計: ${formatFindingsStatsLine(summaryFindings)}`);
line(`review comments 統計: ${formatFindingsStatsLine(sortedComments)}`);