Chromium Code Reviews| 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 os | 12 import os |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 | 15 |
| 16 REVERT_CL_SUBJECT_PREFIX = 'Revert of ' | |
| 17 | |
| 16 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com' | 18 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com' |
| 17 | 19 |
| 18 PUBLIC_API_OWNERS = ( | 20 PUBLIC_API_OWNERS = ( |
| 19 'reed@chromium.org', | 21 'reed@chromium.org', |
| 20 'reed@google.com', | 22 'reed@google.com', |
| 21 'bsalomon@chromium.org', | 23 'bsalomon@chromium.org', |
| 22 'bsalomon@google.com', | 24 'bsalomon@google.com', |
| 23 'rmistry@google.com', # For emergency reverts only. | |
| 24 ) | 25 ) |
| 25 | 26 |
| 26 | 27 |
| 27 def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): | 28 def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): |
| 28 """Checks that files end with atleast one \n (LF).""" | 29 """Checks that files end with atleast one \n (LF).""" |
| 29 eof_files = [] | 30 eof_files = [] |
| 30 for f in input_api.AffectedSourceFiles(source_file_filter): | 31 for f in input_api.AffectedSourceFiles(source_file_filter): |
| 31 contents = input_api.ReadFile(f, 'rb') | 32 contents = input_api.ReadFile(f, 'rb') |
| 32 # Check that the file ends in atleast one newline character. | 33 # Check that the file ends in atleast one newline character. |
| 33 if len(contents) > 1 and contents[-1:] != '\n': | 34 if len(contents) > 1 and contents[-1:] != '\n': |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 requires_owner_check = True | 121 requires_owner_check = True |
| 121 | 122 |
| 122 if not requires_owner_check: | 123 if not requires_owner_check: |
| 123 return results | 124 return results |
| 124 | 125 |
| 125 lgtm_from_owner = False | 126 lgtm_from_owner = False |
| 126 issue = input_api.change.issue | 127 issue = input_api.change.issue |
| 127 if issue and input_api.rietveld: | 128 if issue and input_api.rietveld: |
| 128 issue_properties = input_api.rietveld.get_issue_properties( | 129 issue_properties = input_api.rietveld.get_issue_properties( |
| 129 issue=int(issue), messages=True) | 130 issue=int(issue), messages=True) |
| 131 if issue_properties['subject'].startswith(REVERT_CL_SUBJECT_PREFIX): | |
| 132 # It is a revert CL, ignore the public api owners check. | |
| 133 return results | |
|
borenet
2014/01/31 16:21:58
Seems like there should be a more robust way of do
rmistry
2014/01/31 16:24:00
Which format? the format of the subject? there is
borenet
2014/01/31 16:27:36
Yeah. I think this is okay, but I wish there was
rmistry
2014/01/31 17:29:42
That makes sense, done.
| |
| 130 if issue_properties['owner_email'] in PUBLIC_API_OWNERS: | 134 if issue_properties['owner_email'] in PUBLIC_API_OWNERS: |
| 131 # An owner created the CL that is an automatic LGTM. | 135 # An owner created the CL that is an automatic LGTM. |
| 132 lgtm_from_owner = True | 136 lgtm_from_owner = True |
| 133 | 137 |
| 134 messages = issue_properties.get('messages') | 138 messages = issue_properties.get('messages') |
| 135 if messages: | 139 if messages: |
| 136 for message in messages: | 140 for message in messages: |
| 137 if (message['sender'] in PUBLIC_API_OWNERS and | 141 if (message['sender'] in PUBLIC_API_OWNERS and |
| 138 'lgtm' in message['text'].lower()): | 142 'lgtm' in message['text'].lower()): |
| 139 # Found an lgtm in a message from an owner. | 143 # Found an lgtm in a message from an owner. |
| 140 lgtm_from_owner = True | 144 lgtm_from_owner = True |
| 141 break; | 145 break; |
| 142 | 146 |
| 143 if not lgtm_from_owner: | 147 if not lgtm_from_owner: |
| 144 results.append( | 148 results.append( |
| 145 output_api.PresubmitError( | 149 output_api.PresubmitError( |
| 146 'Since the CL is editing public API, you must have an LGTM from ' | 150 'Since the CL is editing public API, you must have an LGTM from ' |
| 147 'one of: %s' % str(PUBLIC_API_OWNERS))) | 151 'one of: %s' % str(PUBLIC_API_OWNERS))) |
| 148 return results | 152 return results |
| 149 | 153 |
| 150 | 154 |
| 151 def CheckChangeOnCommit(input_api, output_api): | 155 def CheckChangeOnCommit(input_api, output_api): |
| 152 """Presubmit checks for the change on commit. | 156 """Presubmit checks for the change on commit. |
| 153 | 157 |
| 154 The following are the presubmit checks: | 158 The following are the presubmit checks: |
| 155 * Check change has one and only one EOL. | 159 * Check change has one and only one EOL. |
| 156 * Ensures that the Skia tree is open in | 160 * Ensures that the Skia tree is open in |
| 157 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' | 161 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' |
| 158 state and an error if it is in 'Closed' state. | 162 state and an error if it is in 'Closed' state. |
| 159 """ | 163 """ |
| 160 results = [] | 164 results = [] |
| 161 results.extend(_CommonChecks(input_api, output_api)) | 165 results.extend(_CommonChecks(input_api, output_api)) |
| 162 results.extend( | 166 results.extend( |
| 163 _CheckTreeStatus(input_api, output_api, json_url=( | 167 _CheckTreeStatus(input_api, output_api, json_url=( |
| 164 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 168 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
| 165 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 169 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
| 166 return results | 170 return results |
| OLD | NEW |