|
6 | 6 |
|
7 | 7 | const fs = require('fs'); |
8 | 8 | const { spawnSync } = require('child_process'); |
| 9 | +const REVIEW_MARKER = '<!-- nutrient-code-review-action -->'; |
9 | 10 |
|
10 | 11 | // Parse GitHub context from environment |
11 | 12 | const context = { |
@@ -91,6 +92,7 @@ function addReactionsToReview(reviewId) { |
91 | 92 | // Check if a review was posted by this action |
92 | 93 | function isOwnReview(review) { |
93 | 94 | if (!review.body) return false; |
| 95 | + if (review.body.includes(REVIEW_MARKER)) return true; |
94 | 96 |
|
95 | 97 | // Check for our review summary patterns |
96 | 98 | const ownPatterns = [ |
@@ -124,10 +126,13 @@ function dismissStaleReviews() { |
124 | 126 | let dismissedCount = 0; |
125 | 127 | for (const review of reviews) { |
126 | 128 | const isDismissible = review.state === 'APPROVED' || review.state === 'CHANGES_REQUESTED'; |
127 | | - const isBot = review.user && review.user.type === 'Bot'; |
128 | 129 | const isOwn = isOwnReview(review); |
| 130 | + const hasMarker = Boolean(review.body && review.body.includes(REVIEW_MARKER)); |
| 131 | + const isBot = review.user && review.user.type === 'Bot'; |
| 132 | + const canDismissLegacyReview = isBot && isOwn; |
| 133 | + const canDismissMarkedReview = hasMarker; |
129 | 134 |
|
130 | | - if (isBot && isDismissible && isOwn) { |
| 135 | + if (isDismissible && (canDismissMarkedReview || canDismissLegacyReview)) { |
131 | 136 | try { |
132 | 137 | ghApi( |
133 | 138 | `/repos/${context.repo.owner}/${context.repo.repo}/pulls/${context.issue.number}/reviews/${review.id}/dismissals`, |
@@ -231,7 +236,7 @@ async function run() { |
231 | 236 |
|
232 | 237 | const { high: highSeverityCount } = countSeverities(newFindings); |
233 | 238 | const reviewEvent = highSeverityCount > 0 ? 'REQUEST_CHANGES' : 'APPROVE'; |
234 | | - const reviewBody = buildReviewSummary(newFindings); |
| 239 | + const reviewBody = `${buildReviewSummary(newFindings)}\n\n${REVIEW_MARKER}`; |
235 | 240 |
|
236 | 241 | // Prepare review comments |
237 | 242 | const reviewComments = []; |
|
0 commit comments