rmistry@google.com | 8e3ff8c | 2013-01-17 12:55:34 +0000 | [diff] [blame] | 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 |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | |
| 6 | """Top-level presubmit script for Skia. |
| 7 | |
| 8 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 9 | for more details about the presubmit API built into gcl. |
| 10 | """ |
| 11 | |
rmistry@google.com | 6be0b4c | 2013-01-17 14:50:59 +0000 | [diff] [blame] | 12 | def _CommonChecks(input_api, output_api): |
| 13 | """Presubmit checks common to upload and commit.""" |
| 14 | results = [] |
| 15 | sources = lambda x: (x.LocalPath().endswith('.h') or |
| 16 | x.LocalPath().endswith('.gypi') or |
| 17 | x.LocalPath().endswith('.gyp') or |
| 18 | x.LocalPath().endswith('.py') or |
| 19 | x.LocalPath().endswith('.sh') or |
| 20 | x.LocalPath().endswith('.cpp')) |
| 21 | results.extend( |
| 22 | input_api.canned_checks.CheckChangeHasOnlyOneEol( |
| 23 | input_api, output_api, source_file_filter=sources)) |
| 24 | return results |
| 25 | |
rmistry@google.com | 8e3ff8c | 2013-01-17 12:55:34 +0000 | [diff] [blame] | 26 | |
| 27 | def CheckChangeOnUpload(input_api, output_api): |
rmistry@google.com | 6be0b4c | 2013-01-17 14:50:59 +0000 | [diff] [blame] | 28 | """Presubmit checks for the change on upload. |
| 29 | |
| 30 | The following are the presubmit checks: |
| 31 | * Check change has one and only one EOL. |
| 32 | """ |
| 33 | results = [] |
| 34 | results.extend(_CommonChecks(input_api, output_api)) |
| 35 | return results |
rmistry@google.com | 8e3ff8c | 2013-01-17 12:55:34 +0000 | [diff] [blame] | 36 | |
| 37 | |
| 38 | def CheckChangeOnCommit(input_api, output_api): |
| 39 | """Presubmit checks for the change on commit. |
| 40 | |
| 41 | The following are the presubmit checks: |
rmistry@google.com | 6be0b4c | 2013-01-17 14:50:59 +0000 | [diff] [blame] | 42 | * Check change has one and only one EOL. |
rmistry@google.com | 8e3ff8c | 2013-01-17 12:55:34 +0000 | [diff] [blame] | 43 | * Ensures that the Skia tree is not closed in |
| 44 | http://skia-tree-status.appspot.com/ |
| 45 | """ |
| 46 | results = [] |
rmistry@google.com | 6be0b4c | 2013-01-17 14:50:59 +0000 | [diff] [blame] | 47 | results.extend(_CommonChecks(input_api, output_api)) |
rmistry@google.com | 8e3ff8c | 2013-01-17 12:55:34 +0000 | [diff] [blame] | 48 | results.extend( |
| 49 | input_api.canned_checks.CheckTreeIsOpen( |
| 50 | input_api, output_api, json_url=( |
| 51 | 'http://skia-tree-status.appspot.com/banner-status?format=json'))) |
| 52 | return results |