Skip to content

Commit f9d9723

Browse files
committed
Fix: exclude PR author from assigned count — author cannot review their own PR
1 parent 9fb3069 commit f9d9723

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/auto-assign-reviewers.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ jobs:
9090
9191
// Assigns reviewers to a single PR, mutating load/activeCount in place.
9292
async function assignReviewers(pr, load, activeCount) {
93-
const assigned = getPoolAssignees(pr);
93+
const author = pr.user.login;
94+
// Exclude the author from assigned count — they can't review their own PR.
95+
const assigned = getPoolAssignees(pr).filter((a) => a !== author);
9496
const needed = REQUIRED_REVIEWERS - assigned.length;
9597
const weight = getWeight(pr);
9698
@@ -153,8 +155,9 @@ jobs:
153155
return;
154156
}
155157
const assigned = getPoolAssignees(triggerPR);
156-
if (assigned.length >= REQUIRED_REVIEWERS) {
157-
core.info(`Triggering PR #${triggerPR.number} already has ${assigned.length} pool assignees. Exiting.`);
158+
const author = triggerPR.user.login;
159+
if (assigned.filter((a) => a !== author).length >= REQUIRED_REVIEWERS) {
160+
core.info(`Triggering PR #${triggerPR.number} already has ${assigned.length} pool assignees (excl. author). Exiting.`);
158161
return;
159162
}
160163
core.info(`Triggering PR #${triggerPR.number} needs reviewers. Proceeding with load calculation.`);
@@ -200,7 +203,10 @@ jobs:
200203
} else {
201204
// Full-scan mode (workflow_dispatch / schedule): process all eligible PRs that need reviewers.
202205
const needsReviewers = eligiblePRs
203-
.filter((pr) => getPoolAssignees(pr).length < REQUIRED_REVIEWERS)
206+
.filter((pr) => {
207+
const assigned = getPoolAssignees(pr).filter((a) => a !== pr.user.login);
208+
return assigned.length < REQUIRED_REVIEWERS;
209+
})
204210
.sort((a, b) => getWeight(b) - getWeight(a));
205211
206212
core.info(`PRs needing reviewers: ${needsReviewers.length}`);

0 commit comments

Comments
 (0)