fix(review publish): 降級處理 Gitea review 批次發布失敗
This commit is contained in:
+20
-1
@@ -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)}`);
|
||||
|
||||
Reference in New Issue
Block a user