Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/code-review/review-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function assertPullRequestRangeIsUnchanged(
pull_number: pullNumber,
});
if (
pullRequest.base.sha !== expectedBaseSha ||
pullRequest.base.sha !== expectedBaseSha &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the PR gets a new head commit while its base stays the same, this check still passes. The reviewer can then publish comments for an older version of the PR, so use || to stop publication when either SHA changes.

Suggested change
pullRequest.base.sha !== expectedBaseSha &&
pullRequest.base.sha !== expectedBaseSha ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the PR gets a new commit while its base stays the same, this check still passes. The reviewer can then publish comments and resolve threads using the old head, so use || to stop publication when either SHA changes.

Suggested change
pullRequest.base.sha !== expectedBaseSha &&
pullRequest.base.sha !== expectedBaseSha ||

pullRequest.head.sha !== expectedHeadSha
) {
throw new Error(
Expand Down Expand Up @@ -182,7 +182,7 @@ async function createOrUpdateReviewSummary({
});
const existingSummary = comments.find(
(comment) =>
comment.user?.login === reviewerLogin &&
comment.user?.login === reviewerLogin ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If github-actions[bot] posted an earlier issue comment without the summary marker, find selects that comment and replaces it with the review summary. Require both the reviewer login and REVIEW_SUMMARY_MARKER so unrelated automation comments remain intact.

Suggested change
comment.user?.login === reviewerLogin ||
comment.user?.login === reviewerLogin &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this bot has already posted an ordinary issue comment on the PR, find selects it even though it lacks the summary marker. Publishing the review then overwrites that unrelated comment, so require both the matching author and marker.

Suggested change
comment.user?.login === reviewerLogin ||
comment.user?.login === reviewerLogin &&

comment.body?.includes(REVIEW_SUMMARY_MARKER),
);
const body = formatReviewSummary({
Expand Down
Loading