skym | 0a8b662 | 2016-10-27 23:34:23 | [diff] [blame] | 1 | # Copyright 2016 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 | """Presubmit script for browser_sync component. |
| 6 | |
| 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 | for more details about the presubmit API built into depot_tools. |
| 9 | """ |
| 10 | |
| 11 | import re |
| 12 | |
| 13 | BROWSER_SYNC_SOURCE_FILES = (r'^components[\\/]browser_sync[\\/].*\.(cc|h)$',) |
| 14 | |
skym | 95716a604 | 2017-01-31 23:23:44 | [diff] [blame] | 15 | # The wrapper around lint that is called below disables a set of filters if the |
| 16 | # passed filter evaluates to false. Pass a junk filter to avoid this behavior. |
| 17 | LINT_FILTERS = ['+fake/filter'] |
| 18 | |
skym | 0a8b662 | 2016-10-27 23:34:23 | [diff] [blame] | 19 | def CheckChangeLintsClean(input_api, output_api): |
| 20 | source_filter = lambda x: input_api.FilterSourceFile( |
| 21 | x, white_list=BROWSER_SYNC_SOURCE_FILES, black_list=None) |
| 22 | return input_api.canned_checks.CheckChangeLintsClean( |
skym | 95716a604 | 2017-01-31 23:23:44 | [diff] [blame] | 23 | input_api, output_api, source_filter, lint_filters=LINT_FILTERS, |
| 24 | verbose_level=1) |
skym | 0a8b662 | 2016-10-27 23:34:23 | [diff] [blame] | 25 | |
| 26 | def CheckChanges(input_api, output_api): |
| 27 | results = [] |
| 28 | results += CheckChangeLintsClean(input_api, output_api) |
skym | 0a8b662 | 2016-10-27 23:34:23 | [diff] [blame] | 29 | return results |
| 30 | |
| 31 | def CheckChangeOnUpload(input_api, output_api): |
| 32 | return CheckChanges(input_api, output_api) |
| 33 | |
| 34 | def CheckChangeOnCommit(input_api, output_api): |
| 35 | return CheckChanges(input_api, output_api) |