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 """ |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 results = [] | 111 results = [] |
| 112 if failing_files: | 112 if failing_files: |
| 113 results.append( | 113 results.append( |
| 114 output_api.PresubmitError( | 114 output_api.PresubmitError( |
| 115 'The following files have #if or #ifdef before includes:\n%s\n\n' | 115 'The following files have #if or #ifdef before includes:\n%s\n\n' |
| 116 'See skbug.com/3362 for why this should be fixed.' % | 116 'See skbug.com/3362 for why this should be fixed.' % |
| 117 '\n'.join(failing_files))) | 117 '\n'.join(failing_files))) |
| 118 return results | 118 return results |
| 119 | 119 |
| 120 | 120 |
| 121 def _CopyrightChecks(input_api, output_api, source_file_filter=None): | |
| 122 results = [] | |
| 123 year_pattern = r'\d{4}' | |
| 124 year_range_pattern = r'%s(-%s)?' % (year_pattern, year_pattern) | |
| 125 years_pattern = r'%s(,%s)*,?' % (year_range_pattern, year_range_pattern) | |
| 126 copyright_pattern = ( | |
| 127 r'Copyright (\([cC]\) )?%s %s' % (years_pattern, '%s')) | |
| 128 owners = [ | |
| 129 'ARM Ltd.', | |
| 130 'Code Aurora Forum. All rights reserved.', | |
| 131 'Google,? Inc\.?( All rights reserved.)?', | |
| 132 'Intel Inc.', | |
| 133 'Lua.org, PUC-Rio', | |
| 134 'Skia', | |
| 135 'The Android Open Source Project', | |
| 136 'The Chromium Authors. All rights reserved.', | |
| 137 'The Native Client Authors. All rights reserved.', | |
|
borenet
2015/03/23 14:38:05
I just pulled these from existing copyright notice
mtklein
2015/03/23 14:49:50
Let's both exclude third_party ('Lua.org, PUC-Rio'
borenet
2015/03/23 17:20:35
Done.
| |
| 138 ] | |
| 139 | |
| 140 for affected_file in input_api.AffectedSourceFiles(source_file_filter): | |
| 141 contents = input_api.ReadFile(affected_file, 'rb') | |
| 142 found = False | |
| 143 for owner in owners: | |
| 144 if re.search(copyright_pattern % owner, contents): | |
| 145 found = True | |
| 146 break | |
| 147 if not found: | |
| 148 results.append(output_api.PresubmitError( | |
| 149 '%s is missing a correct copyright header.' % affected_file)) | |
| 150 return results | |
| 151 | |
| 152 | |
| 121 def _CommonChecks(input_api, output_api): | 153 def _CommonChecks(input_api, output_api): |
| 122 """Presubmit checks common to upload and commit.""" | 154 """Presubmit checks common to upload and commit.""" |
| 123 results = [] | 155 results = [] |
| 124 sources = lambda x: (x.LocalPath().endswith('.h') or | 156 sources = lambda x: (x.LocalPath().endswith('.h') or |
| 125 x.LocalPath().endswith('.gypi') or | 157 x.LocalPath().endswith('.gypi') or |
| 126 x.LocalPath().endswith('.gyp') or | 158 x.LocalPath().endswith('.gyp') or |
| 127 x.LocalPath().endswith('.py') or | 159 x.LocalPath().endswith('.py') or |
| 128 x.LocalPath().endswith('.sh') or | 160 x.LocalPath().endswith('.sh') or |
| 129 x.LocalPath().endswith('.cpp')) | 161 x.LocalPath().endswith('.cpp')) |
| 130 results.extend( | 162 results.extend( |
| 131 _CheckChangeHasEol( | 163 _CheckChangeHasEol( |
| 132 input_api, output_api, source_file_filter=sources)) | 164 input_api, output_api, source_file_filter=sources)) |
| 133 results.extend(_PythonChecks(input_api, output_api)) | 165 results.extend(_PythonChecks(input_api, output_api)) |
| 134 results.extend(_IfDefChecks(input_api, output_api)) | 166 results.extend(_IfDefChecks(input_api, output_api)) |
| 167 results.extend(_CopyrightChecks(input_api, output_api, | |
| 168 source_file_filter=sources)) | |
| 135 return results | 169 return results |
| 136 | 170 |
| 137 | 171 |
| 138 def CheckChangeOnUpload(input_api, output_api): | 172 def CheckChangeOnUpload(input_api, output_api): |
| 139 """Presubmit checks for the change on upload. | 173 """Presubmit checks for the change on upload. |
| 140 | 174 |
| 141 The following are the presubmit checks: | 175 The following are the presubmit checks: |
| 142 * Check change has one and only one EOL. | 176 * Check change has one and only one EOL. |
| 143 """ | 177 """ |
| 144 results = [] | 178 results = [] |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 state and an error if it is in 'Closed' state. | 414 state and an error if it is in 'Closed' state. |
| 381 """ | 415 """ |
| 382 results = [] | 416 results = [] |
| 383 results.extend(_CommonChecks(input_api, output_api)) | 417 results.extend(_CommonChecks(input_api, output_api)) |
| 384 results.extend( | 418 results.extend( |
| 385 _CheckTreeStatus(input_api, output_api, json_url=( | 419 _CheckTreeStatus(input_api, output_api, json_url=( |
| 386 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 420 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
| 387 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 421 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
| 388 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) | 422 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) |
| 389 return results | 423 return results |
| OLD | NEW |