OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Presubmit script for Chromium browser code. | 5 """Presubmit script for Chromium browser code. |
6 | 6 |
7 This script currently only checks HTML/CSS/JS files in resources/. | 7 This script currently only checks HTML/CSS/JS files in resources/. |
8 | 8 |
9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
10 for more details about the presubmit API built into gcl/git cl, and see | 10 for more details about the presubmit API built into gcl/git cl, and see |
11 http://www.chromium.org/developers/web-development-style-guide for the rules | 11 http://www.chromium.org/developers/web-development-style-guide for the rules |
12 checked for here. | 12 checked for here. |
13 """ | 13 """ |
14 | 14 |
15 | 15 |
16 def CheckChangeOnUpload(input_api, output_api): | 16 def CheckChangeOnUpload(input_api, output_api): |
17 return _CommonChecks(input_api, output_api) | 17 return _CommonChecks(input_api, output_api) |
18 | 18 |
19 | 19 |
20 def CheckChangeOnCommit(input_api, output_api): | 20 def CheckChangeOnCommit(input_api, output_api): |
21 return _CommonChecks(input_api, output_api) | 21 return _CommonChecks(input_api, output_api) |
22 | 22 |
| 23 # chrome/browser/about_flags_switches_histogram_ids.h |
| 24 def _CreateAboutFlagsSwitchesHistogramIdsChecker(input_api, output_api): |
| 25 import sys |
| 26 original_sys_path = sys.path |
| 27 |
| 28 try: |
| 29 sys.path.append(input_api.os_path.join( |
| 30 input_api.PresubmitLocalPath(), '..', '..', 'tools', |
| 31 'about_flags_switches_histogram_ids_checker')) |
| 32 from about_flags_switches_histogram_ids_checker \ |
| 33 import AboutFlagsSwitchesHistogramIDsChecker |
| 34 finally: |
| 35 sys.path = original_sys_path |
| 36 |
| 37 return AboutFlagsSwitchesHistogramIDsChecker(input_api, output_api, |
| 38 path='chrome/browser/about_flags_switches_histogram_ids.h') |
23 | 39 |
24 def _CommonChecks(input_api, output_api): | 40 def _CommonChecks(input_api, output_api): |
25 """Checks common to both upload and commit.""" | 41 """Checks common to both upload and commit.""" |
26 results = [] | 42 results = [] |
27 | 43 |
28 path = input_api.os_path | 44 path = input_api.os_path |
29 cwd = input_api.PresubmitLocalPath() | 45 cwd = input_api.PresubmitLocalPath() |
30 resources = path.join(cwd, 'resources') | 46 resources = path.join(cwd, 'resources') |
31 webui = path.join(cwd, 'ui', 'webui') | 47 webui = path.join(cwd, 'ui', 'webui') |
32 | 48 |
(...skipping 26 matching lines...) Expand all Loading... |
59 return (maybe_resource.LocalPath() not in BLACKLIST and | 75 return (maybe_resource.LocalPath() not in BLACKLIST and |
60 _html_css_js_resource(maybe_resource.AbsoluteLocalPath())) | 76 _html_css_js_resource(maybe_resource.AbsoluteLocalPath())) |
61 | 77 |
62 results.extend(css_checker.CSSChecker( | 78 results.extend(css_checker.CSSChecker( |
63 input_api, output_api, file_filter=is_resource).RunChecks()) | 79 input_api, output_api, file_filter=is_resource).RunChecks()) |
64 results.extend(js_checker.JSChecker( | 80 results.extend(js_checker.JSChecker( |
65 input_api, output_api, file_filter=is_resource).RunChecks()) | 81 input_api, output_api, file_filter=is_resource).RunChecks()) |
66 finally: | 82 finally: |
67 sys.path = old_path | 83 sys.path = old_path |
68 | 84 |
| 85 affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles()) |
| 86 if path.join(cwd, 'about_flags_switches_histogram_ids.h') in affected_files : |
| 87 input_api.logging.info("Running AboutFlagsSwitchesHistogramIdsChecker.") |
| 88 results += _CreateAboutFlagsSwitchesHistogramIdsChecker(input_api, |
| 89 output_api).Run() |
| 90 |
69 return results | 91 return results |
OLD | NEW |