Demetrios Papadopoulos | 379d759 | 2019-11-12 19:21:43 | [diff] [blame] | 1 | # Copyright 2019 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 | def CheckChangeOnUpload(input_api, output_api): |
| 7 | return _CommonChecks(input_api, output_api) |
| 8 | |
| 9 | |
| 10 | def CheckChangeOnCommit(input_api, output_api): |
| 11 | return _CommonChecks(input_api, output_api) |
| 12 | |
| 13 | |
| 14 | def _CheckSvgsOptimized(input_api, output_api): |
| 15 | results = [] |
| 16 | try: |
| 17 | import sys |
| 18 | old_sys_path = sys.path[:] |
| 19 | cwd = input_api.PresubmitLocalPath() |
| 20 | sys.path += [input_api.os_path.join(cwd, '..', 'tools')] |
| 21 | from resources import svgo_presubmit |
| 22 | results += svgo_presubmit.CheckOptimized(input_api, output_api) |
| 23 | finally: |
| 24 | sys.path = old_sys_path |
| 25 | return results |
| 26 | |
| 27 | |
| 28 | def _CheckWebDevStyle(input_api, output_api): |
| 29 | results = [] |
| 30 | try: |
| 31 | import sys |
| 32 | old_sys_path = sys.path[:] |
| 33 | cwd = input_api.PresubmitLocalPath() |
| 34 | sys.path += [input_api.os_path.join(cwd, '..', 'tools')] |
| 35 | from web_dev_style import presubmit_support |
| 36 | results += presubmit_support.CheckStyle(input_api, output_api) |
| 37 | finally: |
| 38 | sys.path = old_sys_path |
| 39 | return results |
| 40 | |
| 41 | |
| 42 | def _CommonChecks(input_api, output_api): |
| 43 | results = [] |
| 44 | results += _CheckSvgsOptimized(input_api, output_api) |
| 45 | results += _CheckWebDevStyle(input_api, output_api) |
| 46 | results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api, |
| 47 | check_js=True) |
| 48 | return results |