Skip to content

Commit c323ad3

Browse files
fix(github): keep review-required until required reviewers approve
GitHub's REVIEW_REQUIRED already encodes approval count and CODEOWNERS rules, but any APPROVED latest review was promoted to approved. Only fall back to latest reviews when GitHub reports no verdict. Co-authored-by: Cursor <[email protected]>
1 parent 0f4a130 commit c323ad3

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎packages/source-control-github/src/server/gitHubPullRequestJson.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,20 @@ describe("pull request list decoding", () => {
294294
]);
295295
});
296296

297+
it("keeps review required when an approval falls short of the branch's required count", () => {
298+
const batch = expectSuccess(
299+
decodePullRequestListJson(
300+
listJson([
301+
{
302+
reviewDecision: "REVIEW_REQUIRED",
303+
latestReviews: [{ author: user("octocat"), state: "APPROVED" }],
304+
},
305+
]),
306+
),
307+
);
308+
expect(batch.items.map((entry) => entry.reviewDecision)).toEqual(["review-required"]);
309+
});
310+
297311
it("skips malformed entries but still counts them, so paging does not stop early", () => {
298312
const batch = expectSuccess(
299313
decodePullRequestListJson(listJson([{}, { number: "not-a-number" }])),

‎packages/source-control-github/src/server/gitHubPullRequestJson.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export function toPullRequestActionSummary(
509509
};
510510
}
511511

512-
/** GitHub's reviewDecision ignores reviews outside branch rules, including app approvals. */
512+
/** Prefer GitHub's reviewDecision; only use latest reviews when it is absent (e.g. bot approvals). */
513513
function toReviewDecisionWithReviews(
514514
value: string | null | undefined,
515515
reviews: ReadonlyArray<LatestReviewFields> | undefined,
@@ -518,7 +518,7 @@ function toReviewDecisionWithReviews(
518518
if (summarized === "approved" || summarized === "changes-requested") return summarized;
519519
const states = new Set((reviews ?? []).map((review) => review.state?.trim().toUpperCase() ?? ""));
520520
if (states.has("CHANGES_REQUESTED")) return "changes-requested";
521-
if (states.has("APPROVED")) return "approved";
521+
if (summarized === null && states.has("APPROVED")) return "approved";
522522
return summarized;
523523
}
524524

0 commit comments

Comments
 (0)