| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 """Top-level presubmit script for Skia. | 6 """Top-level presubmit script for Skia. |
| 7 | 7 |
| 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 9 for more details about the presubmit API built into gcl. | 9 for more details about the presubmit API built into gcl. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import fnmatch | 12 import fnmatch |
| 13 import os | 13 import os |
| 14 import re | 14 import re |
| 15 import sys | 15 import sys |
| 16 import traceback | 16 import traceback |
| 17 | 17 |
| 18 | 18 |
| 19 REVERT_CL_SUBJECT_PREFIX = 'Revert ' | 19 REVERT_CL_SUBJECT_PREFIX = 'Revert ' |
| 20 | 20 |
| 21 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com' | 21 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com' |
| 22 | 22 |
| 23 # Please add the complete email address here (and not just 'xyz@' or 'xyz'). |
| 23 PUBLIC_API_OWNERS = ( | 24 PUBLIC_API_OWNERS = ( |
| 24 'reed@chromium.org', | 25 'reed@chromium.org', |
| 25 'reed@google.com', | 26 'reed@google.com', |
| 26 'bsalomon@chromium.org', | 27 'bsalomon@chromium.org', |
| 27 'bsalomon@google.com', | 28 'bsalomon@google.com', |
| 28 'djsollen@chromium.org', | 29 'djsollen@chromium.org', |
| 29 'djsollen@google.com', | 30 'djsollen@google.com', |
| 30 ) | 31 ) |
| 31 | 32 |
| 32 AUTHORS_FILE_NAME = 'AUTHORS' | 33 AUTHORS_FILE_NAME = 'AUTHORS' |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 return results | 200 return results |
| 200 | 201 |
| 201 lgtm_from_owner = False | 202 lgtm_from_owner = False |
| 202 issue = input_api.change.issue | 203 issue = input_api.change.issue |
| 203 if issue and input_api.rietveld: | 204 if issue and input_api.rietveld: |
| 204 issue_properties = input_api.rietveld.get_issue_properties( | 205 issue_properties = input_api.rietveld.get_issue_properties( |
| 205 issue=int(issue), messages=True) | 206 issue=int(issue), messages=True) |
| 206 if re.match(REVERT_CL_SUBJECT_PREFIX, issue_properties['subject'], re.I): | 207 if re.match(REVERT_CL_SUBJECT_PREFIX, issue_properties['subject'], re.I): |
| 207 # It is a revert CL, ignore the public api owners check. | 208 # It is a revert CL, ignore the public api owners check. |
| 208 return results | 209 return results |
| 210 |
| 211 match = re.search(r'^TBR=(.*)$', issue_properties['description'], re.M) |
| 212 if match: |
| 213 tbr_entries = match.group(1).strip().split(',') |
| 214 for owner in PUBLIC_API_OWNERS: |
| 215 if owner in tbr_entries or owner.split('@')[0] in tbr_entries: |
| 216 # If an owner is specified in the TBR= line then ignore the public |
| 217 # api owners check. |
| 218 return results |
| 219 |
| 209 if issue_properties['owner_email'] in PUBLIC_API_OWNERS: | 220 if issue_properties['owner_email'] in PUBLIC_API_OWNERS: |
| 210 # An owner created the CL that is an automatic LGTM. | 221 # An owner created the CL that is an automatic LGTM. |
| 211 lgtm_from_owner = True | 222 lgtm_from_owner = True |
| 212 | 223 |
| 213 messages = issue_properties.get('messages') | 224 messages = issue_properties.get('messages') |
| 214 if messages: | 225 if messages: |
| 215 for message in messages: | 226 for message in messages: |
| 216 if (message['sender'] in PUBLIC_API_OWNERS and | 227 if (message['sender'] in PUBLIC_API_OWNERS and |
| 217 'lgtm' in message['text'].lower()): | 228 'lgtm' in message['text'].lower()): |
| 218 # Found an lgtm in a message from an owner. | 229 # Found an lgtm in a message from an owner. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 237 state and an error if it is in 'Closed' state. | 248 state and an error if it is in 'Closed' state. |
| 238 """ | 249 """ |
| 239 results = [] | 250 results = [] |
| 240 results.extend(_CommonChecks(input_api, output_api)) | 251 results.extend(_CommonChecks(input_api, output_api)) |
| 241 results.extend( | 252 results.extend( |
| 242 _CheckTreeStatus(input_api, output_api, json_url=( | 253 _CheckTreeStatus(input_api, output_api, json_url=( |
| 243 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 254 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
| 244 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 255 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
| 245 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) | 256 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) |
| 246 return results | 257 return results |
| OLD | NEW |