Update the R= line with the actual list of reviewers that approved the CL.
This makes the commit logs much more useful for a build sheriff. Not only he
sees who committed the CL but see who approved it directly at the log. This
should help build sheriffs when they fail to contact the author and want to
fallback on the reviewer for quick questions.
R=dpranke@chromium.org
BUG=76730
Review URL: https://chromiumcodereview.appspot.com/13800021
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@196786 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index ce7c6df..7b708fc 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -647,6 +647,10 @@
return self.RpcServer().get(
'/download/issue%s_%s.diff' % (issue, patchset))
+ def GetApprovingReviewers(self, issue):
+ return get_approving_reviewers(
+ self.RpcServer().get_issue_properties(int(issue), True))
+
def SetIssue(self, issue):
"""Set this branch's issue. If issue=0, clears the issue."""
if issue:
@@ -873,6 +877,22 @@
return cleanup_list(reviewers)
+def get_approving_reviewers(props):
+ """Retrieves the reviewers that approved a CL from the issue properties with
+ messages.
+
+ Note that the list may contain reviewers that are not committer, thus are not
+ considered by the CQ.
+ """
+ return sorted(
+ set(
+ message['sender']
+ for message in props['messages']
+ if message['approval'] and message['sender'] in props['reviewers']
+ )
+ )
+
+
def FindCodereviewSettingsFile(filename='codereview.settings'):
"""Finds the given file starting in the cwd and going up.
@@ -1486,6 +1506,10 @@
# Keep a separate copy for the commit message, because the commit message
# contains the link to the Rietveld issue, while the Rietveld message contains
# the commit viewvc url.
+ # Keep a separate copy for the commit message.
+ if cl.GetIssue():
+ change_desc.update_reviewers(cl.GetApprovingReviewers(cl.GetIssue()))
+
commit_desc = ChangeDescription(change_desc.description)
if cl.GetIssue():
commit_desc.append_footer('Review URL: %s' % cl.GetIssueURL())