Skip to content

Commit 0d7d39d

Browse files
nashifdleach02
authored andcommitted
scripts: set_maintainer: do not re-add self-removed reviewers
If a collaborator removes themselves from the reviewer list, do not attempt to re-add them on changes to the PR. Fixes #67214 Signed-off-by: Anas Nashif <[email protected]>
1 parent 3053484 commit 0d7d39d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

scripts/set_assignees.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def process_pr(gh, maintainer_file, number):
7878

7979
# one liner PRs should be trivial
8080
if pr.commits == 1 and (pr.additions <= 1 and pr.deletions <= 1) and not manifest_change:
81-
labels = {'trivial'}
81+
labels = {'Trivial'}
8282

8383
if len(fn) > 500:
8484
log(f"Too many files changed ({len(fn)}), skipping....")
@@ -181,14 +181,21 @@ def process_pr(gh, maintainer_file, number):
181181
existing_reviewers |= set(r.get_page(page))
182182
page += 1
183183

184-
for c in collab:
184+
# check for reviewers that remove themselves from list of reviewer and
185+
# do not attempt to add them again based on MAINTAINERS file.
186+
self_removal = []
187+
for event in pr.get_issue_events():
188+
if event.event == 'review_request_removed' and event.actor == event.requested_reviewer:
189+
self_removal.append(event.actor)
190+
191+
for collaborator in collab:
185192
try:
186-
u = gh.get_user(c)
187-
if pr.user != u and gh_repo.has_in_collaborators(u):
188-
if u not in existing_reviewers:
189-
reviewers.append(c)
193+
gh_user = gh.get_user(collaborator)
194+
if pr.user != gh_user and gh_repo.has_in_collaborators(gh_user):
195+
if gh_user not in existing_reviewers and gh_user not in self_removal:
196+
reviewers.append(collaborator)
190197
except UnknownObjectException as e:
191-
log(f"Can't get user '{c}', account does not exist anymore? ({e})")
198+
log(f"Can't get user '{collaborator}', account does not exist anymore? ({e})")
192199

193200
if len(existing_reviewers) < 15:
194201
reviewer_vacancy = 15 - len(existing_reviewers)

0 commit comments

Comments
 (0)