aboutsummaryrefslogtreecommitdiffhomepage
path: root/PRESUBMIT.py
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-03 14:18:32 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-03 14:18:32 +0000
commit745e08caf2ad74141ac1e56fd3c2875b548707be (patch)
treebac2ad06dfd919e609865441e8fbdfa6f2d24c86 /PRESUBMIT.py
parent7017288811091427c15da5f97a14ac85a6585ec4 (diff)
Check if the issue owner is in the AUTHORS file in PRESUBMIT.py
BUG=skia:2072 NOTRY=true (SkipBuildbotRuns) R=borenet@google.com, hcm@google.com Author: rmistry@google.com Review URL: https://codereview.chromium.org/131293005 git-svn-id: http://skia.googlecode.com/svn/trunk@13277 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r--PRESUBMIT.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 9d1e9badc7..dc8cb77c0c 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -9,9 +9,11 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into gcl.
"""
+import fnmatch
import os
import re
import sys
+import traceback
REVERT_CL_SUBJECT_PREFIX = 'Revert '
@@ -25,6 +27,8 @@ PUBLIC_API_OWNERS = (
'bsalomon@google.com',
)
+AUTHORS_FILE_NAME = 'AUTHORS'
+
def _CheckChangeHasEol(input_api, output_api, source_file_filter=None):
"""Checks that files end with atleast one \n (LF)."""
@@ -106,6 +110,48 @@ def _CheckTreeStatus(input_api, output_api, json_url):
return tree_status_results
+def _CheckOwnerIsInAuthorsFile(input_api, output_api):
+ results = []
+ issue = input_api.change.issue
+ if issue and input_api.rietveld:
+ issue_properties = input_api.rietveld.get_issue_properties(
+ issue=int(issue), messages=False)
+ owner_email = issue_properties['owner_email']
+
+ try:
+ authors_content = ''
+ for line in open(AUTHORS_FILE_NAME):
+ if not line.startswith('#'):
+ authors_content += line
+ email_fnmatches = re.findall('<(.*)>', authors_content)
+ for email_fnmatch in email_fnmatches:
+ if fnmatch.fnmatch(owner_email, email_fnmatch):
+ # Found a match, the user is in the AUTHORS file break out of the loop
+ break
+ else:
+ # TODO(rmistry): Remove the below CLA messaging once a CLA checker has
+ # been added to the CQ.
+ results.append(
+ output_api.PresubmitError(
+ 'The email %s is not in Skia\'s AUTHORS file.\n'
+ 'Issue owner, this CL must include an addition to the Skia AUTHORS '
+ 'file.\n'
+ 'Googler reviewers, please check that the AUTHORS entry '
+ 'corresponds to an email address in http://goto/cla-signers. If it '
+ 'does not then ask the issue owner to sign the CLA at '
+ 'https://developers.google.com/open-source/cla/individual '
+ '(individual) or '
+ 'https://developers.google.com/open-source/cla/corporate '
+ '(corporate).'
+ % owner_email))
+ except IOError:
+ # Do not fail if authors file cannot be found.
+ traceback.print_exc()
+ input_api.logging.error('AUTHORS file not found!')
+
+ return results
+
+
def _CheckLGTMsForPublicAPI(input_api, output_api):
"""Check LGTMs for public API changes.
@@ -168,4 +214,5 @@ def CheckChangeOnCommit(input_api, output_api):
_CheckTreeStatus(input_api, output_api, json_url=(
SKIA_TREE_STATUS_URL + '/banner-status?format=json')))
results.extend(_CheckLGTMsForPublicAPI(input_api, output_api))
+ results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api))
return results