feat: add status banner and collapsible unposted findings to review body (6.1)
This commit is contained in:
1 parent
d9666c94a7
commit
a35587e2ef
2 files changed
+29
-4
No files matched your search
+24
-3
@@ -16,6 +16,8 @@ export function formatReviewBody(
|
|||||||
formatReviewStateMarker(mode, disposition, decision.review.length, decision.change.length),
|
formatReviewStateMarker(mode, disposition, decision.review.length, decision.change.length),
|
||||||
`## Automated review`,
|
`## Automated review`,
|
||||||
"",
|
"",
|
||||||
|
formatStatusBanner(disposition, decision),
|
||||||
|
"",
|
||||||
`Mode: ${mode}`,
|
`Mode: ${mode}`,
|
||||||
""
|
""
|
||||||
];
|
];
|
||||||
@@ -54,8 +56,8 @@ export function formatReviewBody(
|
|||||||
`Applied review policy: ${config.reviewPolicy}`,
|
`Applied review policy: ${config.reviewPolicy}`,
|
||||||
`Final status: ${formatDisposition(disposition)}`,
|
`Final status: ${formatDisposition(disposition)}`,
|
||||||
"",
|
"",
|
||||||
`Required changes: ${decision.change.length}`,
|
`**Required changes: ${decision.change.length}**`,
|
||||||
`Review notes: ${decision.review.length}`
|
`**Review notes: ${decision.review.length}**`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (decision.change.length > 0 && !decision.result.shouldClosePullRequest) {
|
if (decision.change.length > 0 && !decision.result.shouldClosePullRequest) {
|
||||||
@@ -63,7 +65,12 @@ export function formatReviewBody(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (unpostedFindings.length > 0) {
|
if (unpostedFindings.length > 0) {
|
||||||
lines.push("", "Findings that could not be attached inline:");
|
lines.push(
|
||||||
|
"",
|
||||||
|
"<details>",
|
||||||
|
`<summary>Findings that could not be attached inline (${unpostedFindings.length})</summary>`,
|
||||||
|
""
|
||||||
|
);
|
||||||
for (const finding of unpostedFindings) {
|
for (const finding of unpostedFindings) {
|
||||||
lines.push(
|
lines.push(
|
||||||
"",
|
"",
|
||||||
@@ -71,11 +78,25 @@ export function formatReviewBody(
|
|||||||
` ${finding.body}`
|
` ${finding.body}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
lines.push("", "</details>");
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines.join("\n");
|
return lines.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatStatusBanner(disposition: ReviewDisposition, decision: ReviewDecision): string {
|
||||||
|
if (decision.result.shouldClosePullRequest) {
|
||||||
|
return "> 🚨 **Malicious code detected — this pull request will be closed.**";
|
||||||
|
}
|
||||||
|
if (disposition.blocksMerge) {
|
||||||
|
return "> ❌ **Changes requested** — blocking findings must be fixed before merge.";
|
||||||
|
}
|
||||||
|
if (disposition.requiresAdminApproval) {
|
||||||
|
return "> ⏸️ **Waiting for administrator approval** — review notes require an admin approval of this head commit.";
|
||||||
|
}
|
||||||
|
return "> ✅ **Safe to merge** under the configured review policy.";
|
||||||
|
}
|
||||||
|
|
||||||
export function formatFindingReviewBody(
|
export function formatFindingReviewBody(
|
||||||
decision: ReviewDecision,
|
decision: ReviewDecision,
|
||||||
category: "review" | "change",
|
category: "review" | "change",
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ test("clean pass body shows the approve summary and merge guidance", () => {
|
|||||||
assert.match(body, /Final status: safe to merge/);
|
assert.match(body, /Final status: safe to merge/);
|
||||||
assert.match(body, /Model decision: safe to merge/);
|
assert.match(body, /Model decision: safe to merge/);
|
||||||
assert.match(body, /Applied review policy/);
|
assert.match(body, /Applied review policy/);
|
||||||
|
assert.match(body, /✅ \*\*Safe to merge\*\*/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("blocked body lists unposted findings and recheck hint", () => {
|
test("blocked body lists unposted findings and recheck hint", () => {
|
||||||
@@ -56,13 +57,16 @@ test("blocked body lists unposted findings and recheck hint", () => {
|
|||||||
blockDisposition
|
blockDisposition
|
||||||
);
|
);
|
||||||
assert.match(body, /Final status: changes requested/);
|
assert.match(body, /Final status: changes requested/);
|
||||||
assert.match(body, /could not be attached inline/);
|
assert.match(body, /❌ \*\*Changes requested\*\*/);
|
||||||
|
assert.match(body, /<details>/);
|
||||||
|
assert.match(body, /could not be attached inline \(1\)/);
|
||||||
assert.match(body, /\/recheck/);
|
assert.match(body, /\/recheck/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("admin approval body states the waiting disposition", () => {
|
test("admin approval body states the waiting disposition", () => {
|
||||||
const body = formatReviewBody(decision(), [], mode, adminDisposition);
|
const body = formatReviewBody(decision(), [], mode, adminDisposition);
|
||||||
assert.match(body, /waiting for repository administrator approval/);
|
assert.match(body, /waiting for repository administrator approval/);
|
||||||
|
assert.match(body, /⏸️ \*\*Waiting for administrator approval\*\*/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("finding bodies carry the state marker and finding count", () => {
|
test("finding bodies carry the state marker and finding count", () => {
|
||||||
|
|||||||
Reference in new issue
Block a user