aboutsummaryrefslogtreecommitdiffhomepage
path: root/PRESUBMIT.py
diff options
context:
space:
mode:
authorGravatar Ravi Mistry <rmistry@google.com>2016-10-05 08:41:12 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-05 16:38:38 +0000
commit39eabb6ccba244f47534ed5a2a961596777904f4 (patch)
treef18e0d725e2dc84a272f39e340abfb259d5e91a6 /PRESUBMIT.py
parent088e21ba652ceaa4abb4ba8cdd2ec1bc8afc32ed (diff)
PRESUBMIT.py improvements
* Updated code to check for owners in reviewers for Gerrit issues instead for in the TBR= line. * The previous TBR parsing code was not accounting for adding comments. Eg: "TBR=rmistry (Testing only)". BUG=skia:5825 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2981 Change-Id: I910a3ae71a9f57c14f80c0b0404041cbe451a77c Reviewed-on: https://skia-review.googlesource.com/2981 Reviewed-by: Joe Gregorio <jcgregorio@google.com> Commit-Queue: Ravi Mistry <rmistry@google.com>
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r--PRESUBMIT.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 4798a02d59..320e63d03a 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -334,11 +334,20 @@ class CodeReview(object):
else:
return self._rietveld_properties['cq_dry_run']
+ def GetReviewers(self):
+ if self._gerrit:
+ code_review_label = (
+ self._gerrit.GetChangeInfo(self._issue)['labels']['Code-Review'])
+ return [r['email'] for r in code_review_label.get('all', [])]
+ else:
+ return self._rietveld_properties['reviewers']
+
def GetApprovers(self):
approvers = []
if self._gerrit:
- for m in self._gerrit.GetChangeInfo(
- self._issue)['labels']['Code-Review']['all']:
+ code_review_label = (
+ self._gerrit.GetChangeInfo(self._issue)['labels']['Code-Review'])
+ for m in code_review_label.get('all', []):
if m.get("value") == 1:
approvers.append(m["email"])
else:
@@ -413,14 +422,22 @@ def _CheckLGTMsForPublicAPI(input_api, output_api):
# going to be committed.
return results
- match = re.search(r'^TBR=(.*)$', cr.GetDescription(), re.M)
- if match:
- tbr_entries = match.group(1).strip().split(',')
- for owner in PUBLIC_API_OWNERS:
- if owner in tbr_entries or owner.split('@')[0] in tbr_entries:
- # If an owner is specified in the TBR= line then ignore the public
- # api owners check.
+ if input_api.gerrit:
+ for reviewer in cr.GetReviewers():
+ if reviewer in PUBLIC_API_OWNERS:
+ # If an owner is specified as an reviewer in Gerrit then ignore the
+ # public api owners check.
return results
+ else:
+ match = re.search(r'^TBR=(.*)$', cr.GetDescription(), re.M)
+ if match:
+ tbr_section = match.group(1).strip().split(' ')[0]
+ tbr_entries = tbr_section.split(',')
+ for owner in PUBLIC_API_OWNERS:
+ if owner in tbr_entries or owner.split('@')[0] in tbr_entries:
+ # If an owner is specified in the TBR= line then ignore the public
+ # api owners check.
+ return results
if cr.GetOwnerEmail() in PUBLIC_API_OWNERS:
# An owner created the CL that is an automatic LGTM.