summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorOrgad Shaneh <orgads@gmail.com>2013-04-11 13:42:56 +0300
committerOrgad Shaneh <orgads@gmail.com>2013-04-11 22:01:52 +0300
commit67ad391ee05255ee068085965448579f10546d27 (patch)
tree83d8899705d43d4ebc2150ac7bd2af02418fbe89 /contrib
parenteecfa12b271ba1acaff41b2f333b5e7f61daa616 (diff)
TrivialRebase: Aggregate approvals
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/trivial_rebase.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/contrib/trivial_rebase.py b/contrib/trivial_rebase.py
index 3e77c4c9cf..0a0e5104cd 100755
--- a/contrib/trivial_rebase.py
+++ b/contrib/trivial_rebase.py
@@ -137,6 +137,13 @@ class TrivialRebase:
approvals.append(data["columns"])
return approvals
+ def AppendAcctApproval(self, account_id, value):
+ try:
+ newval = self.acct_approvals[account_id] + ' ' + value
+ except KeyError:
+ newval = value
+ self.acct_approvals[account_id] = newval
+
def GetEmailFromAcctId(self, account_id):
"""Returns the preferred email address associated with the account_id"""
sql_query = ("\"SELECT preferred_email FROM accounts WHERE account_id = %s\""
@@ -207,17 +214,16 @@ class TrivialRebase:
# Need to get all approvals on prior patch set, then suexec them onto
# this patchset.
approvals = self.GetApprovals()
- gerrit_approve_msg = ("\'Automatically re-added by Gerrit trivial rebase "
- "detection script.\'")
+ self.acct_approvals = dict()
for approval in approvals:
# Note: Sites with different 'copy_min_score' values in the
# approval_categories DB table might want different behavior here.
# Additional categories should also be added if desired.
if approval["category_id"] == "CRVW":
- approve_category = '--code-review'
+ self.AppendAcctApproval(approval['account_id'], '--code-review %s' % approval['value'])
elif approval["category_id"] == "VRIF":
# Don't re-add verifies
- #approve_category = '--verified'
+ # self.AppendAcctApproval(approval['account_id'], '--verified %s' % approval['value'])
continue
elif approval["category_id"] == "SUBM":
# We don't care about previous submit attempts
@@ -226,11 +232,12 @@ class TrivialRebase:
print "Unsupported category: %s" % approval
continue
- score = approval["value"]
+ gerrit_approve_msg = ("\'Automatically re-added by Gerrit trivial rebase "
+ "detection script.\'")
+ for acct, flags in self.acct_approvals.items():
gerrit_approve_cmd = ['gerrit', 'approve', '--project', self.project,
- '--message', gerrit_approve_msg, approve_category,
- score, self.commit]
- email_addr = self.GetEmailFromAcctId(approval["account_id"])
+ '--message', gerrit_approve_msg, flags, self.commit]
+ email_addr = self.GetEmailFromAcctId(acct)
self.SuExec(email_addr, ' '.join(gerrit_approve_cmd))
if __name__ == "__main__":