From c4f54692b0751e57888c606a265d11b7d2ba4bcb Mon Sep 17 00:00:00 2001 From: Brennen Bearnes Date: Mon, 8 May 2023 16:51:10 -0600 Subject: [PATCH] add CodeReviewBot PHID CodeReviewBot is intended for use with GitLab-Phabricator integrations. Has a generic name in case we want to use it with tools other than GitLab at any point. For https://phabricator.wikimedia.org/T330923 Bug: T330923 # Subject: summary of your change # * "If applied, this commit will..." # * Imperative mood: Change/Add/Fix/Remove/Update/Refactor/Document # * Optionally, prefix with subject / component (general area modified) # * https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines#Subject # Body: # * Why? What's wrong with status quo? Are there other ways? # * How to test/confirm? # * https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines#Body # Bug: TXXXXXX # # Other fields: # ~/code/bpb-kit/home/cheatsheets/git-meta.txt --- patchforreview_remover.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/patchforreview_remover.py b/patchforreview_remover.py index 184f1fe..e575a74 100755 --- a/patchforreview_remover.py +++ b/patchforreview_remover.py @@ -6,8 +6,9 @@ from lib import Client class Checker(): - def __init__(self, gerrit_bot_phid, project_patch_for_review_phid, client): + def __init__(self, gerrit_bot_phid, code_review_bot_phid, project_patch_for_review_phid, client): self.gerrit_bot_phid = gerrit_bot_phid + self.code_review_bot_phid = code_review_bot_phid self.project_patch_for_review_phid = project_patch_for_review_phid self.client = client @@ -61,7 +62,7 @@ class Checker(): for transaction in self.client.getTransactions(phid): if re.findall(re.escape('https://github.com/') + r'.+?/pull', str(transaction)): return False - if transaction['authorPHID'] == self.gerrit_bot_phid: + if transaction['authorPHID'] in [self.gerrit_bot_phid, self.code_review_bot_phid]: gerrit_bot_actions.append(transaction) else: # If someone other than GerritBot adds the Patch-For-Review project, don't @@ -106,9 +107,11 @@ if __name__ == "__main__": client = Client.newFromCreds() gerrit_bot_phid = 'PHID-USER-idceizaw6elwiwm5xshb' + code_review_bot_phid = 'PHID-USER-ckazlx2gejbyo75y6lid' project_patch_for_review_phid = 'PHID-PROJ-onnxucoedheq3jevknyr' checker = Checker( gerrit_bot_phid, + code_review_bot_phid, project_patch_for_review_phid, client) gen = client.getTasksWithProject(project_patch_for_review_phid)