ci/github-script/reviewers: improve "needs: reviewers" label

This should fix the bug where the "needs: reviewer" label was set too
early, just to be removed immediately, because reviewers were then
requested.
This commit is contained in:
Wolfgang Walther 2025-11-04 18:29:12 +01:00
parent a23d0ab24c
commit e68b0aef13
No known key found for this signature in database
GPG key ID: B39893FA5F65CAE1
2 changed files with 13 additions and 2 deletions

View file

@ -375,7 +375,10 @@ module.exports = async ({ github, context, core, dry }) => {
})
if (!pull_request.draft) {
await handleReviewers({
// We set this label earlier already, but the current PR state can be very different
// after handleReviewers has requested reviews, so update it in this case to prevent
// this label from flip-flopping.
prLabels['9.needs: reviewer'] = await handleReviewers({
github,
context,
core,

View file

@ -68,7 +68,8 @@ async function handleReviewers({
log(
`Too many reviewers (${reviewers.join(', ')}), skipping review requests.`,
)
return
// false indicates, that we do have reviewers and don't need the "needs: reviewers" label.
return false
}
const requested_reviewers = new Set(
@ -113,6 +114,13 @@ async function handleReviewers({
reviewers,
})
}
// Return a boolean on whether the "needs: reviewers" label should be set.
return (
new_reviewers.size === 0 &&
existing_reviewers.size === 0 &&
requested_reviewers.size === 0
)
}
module.exports = {