Skip to content

Commit

Permalink
Dismiss bot review when marked as ready (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Oct 3, 2023
1 parent 5ddfe69 commit 89ae599
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions services/bots/src/github-webhook/handlers/review_drafter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ export class ReviewDrafter extends BaseWebhookHandler {
const { data: reviews } = await context.github.pulls.listReviews(
context.pullRequest({ per_page: 100 }),
);

const requestedChanges = reviews.filter((review) => review.state === 'CHANGES_REQUESTED');
const reviewers = new Set(
reviews
.filter((review) => review.state === 'CHANGES_REQUESTED')
requestedChanges
.filter(
// Sometimes GitHub sends it as "bot" and sometimes as "Bot
(review) => review.user.type.toLowerCase() !== 'bot',
)
.map((review) => review.user.login),
);

Expand All @@ -101,5 +106,17 @@ export class ReviewDrafter extends BaseWebhookHandler {
context.pullRequest({ reviewers: Array.from(reviewers) }),
);
}

const botReviewes = requestedChanges.filter(
// Sometimes GitHub sends it as "bot" and sometimes as "Bot
(review) => review.user.type.toLowerCase() === 'bot',
);

for (const review of botReviewes) {
// Dismiss all bot reviews
await context.github.pulls.dismissReview(
context.pullRequest({ review_id: review.id, message: 'Stale' }),
);
}
}
}

0 comments on commit 89ae599

Please sign in to comment.