Hoa Nguyen has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/50187 )

Change subject: util: Make gerrit bot respect reviewer removal
......................................................................

util: Make gerrit bot respect reviewer removal

Currently, if a maintainer is removed from a change, the maintainer
will be added again. This change prevents the bot from adding the
removed maintainer again.

The bot will query all updates related to reviewer addition/removal
for each new change. If a reviewer has ever been added/removed
from a change, that reviewer won't be added to that change again.

Change-Id: Ifaab5ebd7ebf3e6453b2551d3e37c1b9e214c906
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
---
M util/gerrit-bot/bot.py
M util/gerrit-bot/util.py
2 files changed, 14 insertions(+), 3 deletions(-)



diff --git a/util/gerrit-bot/bot.py b/util/gerrit-bot/bot.py
index 709279c..6f6b018 100755
--- a/util/gerrit-bot/bot.py
+++ b/util/gerrit-bot/bot.py
@@ -170,9 +170,10 @@
     def __query_new_changes(self, query_age):
         query = (f"projects:{self.config.projects_prefix} "
                  f"status:open -is:wip -age:{query_age}")
-        response = self.gerrit_api.query_changes(query,
-                                                 self.config.query_limit,
-                                                 "CURRENT_REVISION")
+        response = self.gerrit_api.query_changes(
+            query, self.config.query_limit,
+            ["CURRENT_REVISION", "REVIEWER_UPDATES", "DETAILED_ACCOUNTS"]
+        )

         if response.status_code >= 300:
             print("Error: Couldn't query new Gerrit changes")
diff --git a/util/gerrit-bot/util.py b/util/gerrit-bot/util.py
index d836690..a5142e4 100644
--- a/util/gerrit-bot/util.py
+++ b/util/gerrit-bot/util.py
@@ -60,6 +60,14 @@
     tags, message = parse_commit_subject(change["subject"])
     change_id = change["id"]
     maintainer_emails = set()
+
+    # There are cases that a reviewer being removed from the reviewer list
+    # by another reviewer. We want to respect this removal. To do this,
+    # we can avoid adding reviewers that have been added/removed to the
+    # reviewer list.
+    avoid_emails = set()
+    for update in change["reviewer_updates"]:
+        avoid_emails = update["reviewer"]["email"]
     for tag in tags:
         try:
             for name, email in maintainers[tag].maintainers:
@@ -68,6 +76,8 @@
             print((f"warning: `change-{change_id}` has an unknown tag: "
                    f"`{tag}`"))
     for email in maintainer_emails:
+        if email in avoid_emails:
+            continue
         try:
             account_id = maintainers_account_ids[email]
             gerrit_api.add_reviewer(change_id, account_id)

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50187
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ifaab5ebd7ebf3e6453b2551d3e37c1b9e214c906
Gerrit-Change-Number: 50187
Gerrit-PatchSet: 1
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to