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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 """Make sure any .gn files we're changing have been formatted.""" | 189 """Make sure any .gn files we're changing have been formatted.""" |
190 results = [] | 190 results = [] |
191 for f in input_api.AffectedFiles(): | 191 for f in input_api.AffectedFiles(): |
192 if not f.LocalPath().endswith('.gn'): | 192 if not f.LocalPath().endswith('.gn'): |
193 continue | 193 continue |
194 | 194 |
195 cmd = ['gn', 'format', '--dry-run', f.LocalPath()] | 195 cmd = ['gn', 'format', '--dry-run', f.LocalPath()] |
196 try: | 196 try: |
197 subprocess.check_output(cmd) | 197 subprocess.check_output(cmd) |
198 except subprocess.CalledProcessError: | 198 except subprocess.CalledProcessError: |
199 fix = cmd[:] | 199 fix = 'gn format ' + f.LocalPath() |
200 fix[2] = '--in-place' | |
201 results.append(output_api.PresubmitError( | 200 results.append(output_api.PresubmitError( |
202 '`%s` failed, try\n\t%s' % (' '.join(cmd), ' '.join(fix)))) | 201 '`%s` failed, try\n\t%s' % (' '.join(cmd), fix))) |
203 return results | 202 return results |
204 | 203 |
205 | 204 |
206 def _CommonChecks(input_api, output_api): | 205 def _CommonChecks(input_api, output_api): |
207 """Presubmit checks common to upload and commit.""" | 206 """Presubmit checks common to upload and commit.""" |
208 results = [] | 207 results = [] |
209 sources = lambda x: (x.LocalPath().endswith('.h') or | 208 sources = lambda x: (x.LocalPath().endswith('.h') or |
210 x.LocalPath().endswith('.gypi') or | 209 x.LocalPath().endswith('.gypi') or |
211 x.LocalPath().endswith('.gyp') or | 210 x.LocalPath().endswith('.gyp') or |
212 x.LocalPath().endswith('.py') or | 211 x.LocalPath().endswith('.py') or |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 state and an error if it is in 'Closed' state. | 553 state and an error if it is in 'Closed' state. |
555 """ | 554 """ |
556 results = [] | 555 results = [] |
557 results.extend(_CommonChecks(input_api, output_api)) | 556 results.extend(_CommonChecks(input_api, output_api)) |
558 results.extend( | 557 results.extend( |
559 _CheckTreeStatus(input_api, output_api, json_url=( | 558 _CheckTreeStatus(input_api, output_api, json_url=( |
560 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 559 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
561 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 560 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
562 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) | 561 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) |
563 return results | 562 return results |
OLD | NEW |