Skip to content

Commit 3737488

Browse files
committed
Dismiss stale action reviews reliably with review marker
1 parent 37a1142 commit 3737488

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/comment-pr-findings.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
const fs = require('fs');
88
const { spawnSync } = require('child_process');
9+
const REVIEW_MARKER = '<!-- nutrient-code-review-action -->';
910

1011
// PR Summary marker for identifying our summary sections
1112
const PR_SUMMARY_MARKER = '📋 **PR Summary:**';
@@ -102,6 +103,7 @@ function addReactionsToReview(reviewId) {
102103
// Check if a review was posted by this action
103104
function isOwnReview(review) {
104105
if (!review.body) return false;
106+
if (review.body.includes(REVIEW_MARKER)) return true;
105107

106108
// Check for our review summary patterns
107109
const ownPatterns = [
@@ -135,8 +137,8 @@ function findExistingReview() {
135137

136138
for (const review of reviews) {
137139
const isDismissible = review.state === 'APPROVED' || review.state === 'CHANGES_REQUESTED';
138-
const isBot = review.user && review.user.type === 'Bot';
139140
const isOwn = isOwnReview(review);
141+
const isBot = review.user && review.user.type === 'Bot';
140142

141143
if (isBot && isDismissible && isOwn) {
142144
return review;
@@ -293,7 +295,7 @@ async function run() {
293295

294296
const highSeverityCount = analysisSummary.high_severity || 0;
295297
const reviewEvent = highSeverityCount > 0 ? 'REQUEST_CHANGES' : 'APPROVE';
296-
const reviewBody = buildReviewSummary(newFindings, prSummary, analysisSummary);
298+
const reviewBody = `${buildReviewSummary(newFindings, prSummary, analysisSummary)}\n\n${REVIEW_MARKER}`;
297299

298300
// Prepare review comments
299301
const reviewComments = [];

0 commit comments

Comments
 (0)