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 os | 13 import os |
13 import re | 14 import re |
14 import sys | 15 import sys |
16 import traceback | |
15 | 17 |
16 | 18 |
17 REVERT_CL_SUBJECT_PREFIX = 'Revert ' | 19 REVERT_CL_SUBJECT_PREFIX = 'Revert ' |
18 | 20 |
19 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com' | 21 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com' |
20 | 22 |
21 PUBLIC_API_OWNERS = ( | 23 PUBLIC_API_OWNERS = ( |
22 'reed@chromium.org', | 24 'reed@chromium.org', |
23 'reed@google.com', | 25 'reed@google.com', |
24 'bsalomon@chromium.org', | 26 'bsalomon@chromium.org', |
25 'bsalomon@google.com', | 27 'bsalomon@google.com', |
26 ) | 28 ) |
27 | 29 |
30 AUTHORS_FILE_NAME = 'AUTHORS' | |
31 | |
28 | 32 |
29 def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): | 33 def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): |
30 """Checks that files end with atleast one \n (LF).""" | 34 """Checks that files end with atleast one \n (LF).""" |
31 eof_files = [] | 35 eof_files = [] |
32 for f in input_api.AffectedSourceFiles(source_file_filter): | 36 for f in input_api.AffectedSourceFiles(source_file_filter): |
33 contents = input_api.ReadFile(f, 'rb') | 37 contents = input_api.ReadFile(f, 'rb') |
34 # Check that the file ends in atleast one newline character. | 38 # Check that the file ends in atleast one newline character. |
35 if len(contents) > 1 and contents[-1:] != '\n': | 39 if len(contents) > 1 and contents[-1:] != '\n': |
36 eof_files.append(f.LocalPath()) | 40 eof_files.append(f.LocalPath()) |
37 | 41 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 SKIA_TREE_STATUS_URL + '/current-sheriff') | 103 SKIA_TREE_STATUS_URL + '/current-sheriff') |
100 sheriff_details = input_api.json.loads(connection.read()) | 104 sheriff_details = input_api.json.loads(connection.read()) |
101 if sheriff_details: | 105 if sheriff_details: |
102 tree_status_results[0]._message += ( | 106 tree_status_results[0]._message += ( |
103 '\n\nPlease contact the current Skia sheriff (%s) if you are trying ' | 107 '\n\nPlease contact the current Skia sheriff (%s) if you are trying ' |
104 'to submit a build fix\nand do not know how to submit because the ' | 108 'to submit a build fix\nand do not know how to submit because the ' |
105 'tree is closed') % sheriff_details['username'] | 109 'tree is closed') % sheriff_details['username'] |
106 return tree_status_results | 110 return tree_status_results |
107 | 111 |
108 | 112 |
113 def _CheckOwnerIsInAuthorsFile(input_api, output_api): | |
114 results = [] | |
115 issue = input_api.change.issue | |
116 if issue and input_api.rietveld: | |
117 issue_properties = input_api.rietveld.get_issue_properties( | |
118 issue=int(issue), messages=False) | |
119 owner_email = issue_properties['owner_email'] | |
120 | |
121 try: | |
122 authors_content = '' | |
123 for line in open(AUTHORS_FILE_NAME): | |
124 if not line.startswith('#'): | |
125 authors_content += line | |
126 email_fnmatches = re.findall('<(.*)>', authors_content) | |
127 for email_fnmatch in email_fnmatches: | |
128 if fnmatch.fnmatch(owner_email, email_fnmatch): | |
129 # Found a match, the user is in the AUTHORS file break out of the loop | |
130 break | |
131 else: | |
132 # TODO(rmistry): Remove the below CLA messaging once a CLA checker has | |
133 # been added to the CQ. | |
134 results.append( | |
135 output_api.PresubmitError( | |
136 'The email %s is not in Skia\'s AUTHORS file.\n' | |
137 'Issue owner, this CL must include an addition to the Skia AUTHORS ' | |
138 'file.\n' | |
139 'Googler reviewers, please check that the AUTHORS entry ' | |
140 'corresponds to an email address in http://goto/cla-signers. If it ' | |
141 'does not then ask the issue owner to sign the CLA at ' | |
142 'http://code.google.com/legal/individual-cla-v1.0.html ' | |
143 '(individual) or ' | |
144 'http://code.google.com/legal/corporate-cla-v1.0.html (corporate).' | |
145 % owner_email)) | |
borenet
2014/02/03 13:54:00
I think this message could be worded more clearly,
| |
146 except IOError: | |
147 # Do not fail if authors file cannot be found. | |
148 traceback.print_exc() | |
149 input_api.logging.error('AUTHORS file not found!') | |
150 | |
151 return results | |
152 | |
153 | |
109 def _CheckLGTMsForPublicAPI(input_api, output_api): | 154 def _CheckLGTMsForPublicAPI(input_api, output_api): |
110 """Check LGTMs for public API changes. | 155 """Check LGTMs for public API changes. |
111 | 156 |
112 For public API files make sure there is an LGTM from the list of owners in | 157 For public API files make sure there is an LGTM from the list of owners in |
113 PUBLIC_API_OWNERS. | 158 PUBLIC_API_OWNERS. |
114 """ | 159 """ |
115 results = [] | 160 results = [] |
116 requires_owner_check = False | 161 requires_owner_check = False |
117 for affected_svn_file in input_api.AffectedFiles(): | 162 for affected_svn_file in input_api.AffectedFiles(): |
118 affected_file_path = affected_svn_file.AbsoluteLocalPath() | 163 affected_file_path = affected_svn_file.AbsoluteLocalPath() |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 * Ensures that the Skia tree is open in | 206 * Ensures that the Skia tree is open in |
162 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' | 207 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' |
163 state and an error if it is in 'Closed' state. | 208 state and an error if it is in 'Closed' state. |
164 """ | 209 """ |
165 results = [] | 210 results = [] |
166 results.extend(_CommonChecks(input_api, output_api)) | 211 results.extend(_CommonChecks(input_api, output_api)) |
167 results.extend( | 212 results.extend( |
168 _CheckTreeStatus(input_api, output_api, json_url=( | 213 _CheckTreeStatus(input_api, output_api, json_url=( |
169 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 214 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
170 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 215 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
216 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) | |
171 return results | 217 return results |
OLD | NEW |