[email protected] | 516dce2 | 2014-05-01 18:31:53 | [diff] [blame] | 1 | # Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 54caefd | 2012-02-15 06:18:56 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
dbeam | ccf7fef | 2017-05-17 22:24:29 | [diff] [blame] | 5 | """Presubmit script for Chromium browser code.""" |
[email protected] | 54caefd | 2012-02-15 06:18:56 | [diff] [blame] | 6 | |
dougt | b53dc59 | 2017-02-01 16:25:00 | [diff] [blame] | 7 | def _RunHistogramChecks(input_api, output_api, histogram_name): |
| 8 | try: |
lukasza | 14d9a1a | 2017-04-28 15:23:57 | [diff] [blame] | 9 | # Setup sys.path so that we can call histograms code. |
dougt | b53dc59 | 2017-02-01 16:25:00 | [diff] [blame] | 10 | import sys |
| 11 | original_sys_path = sys.path |
| 12 | sys.path = sys.path + [input_api.os_path.join( |
| 13 | input_api.change.RepositoryRoot(), |
| 14 | 'tools', 'metrics', 'histograms')] |
| 15 | |
alexmos | 7f7bae6 | 2017-04-05 21:15:04 | [diff] [blame] | 16 | results = [] |
| 17 | |
dougt | b53dc59 | 2017-02-01 16:25:00 | [diff] [blame] | 18 | import presubmit_bad_message_reasons |
alexmos | 7f7bae6 | 2017-04-05 21:15:04 | [diff] [blame] | 19 | results.extend(presubmit_bad_message_reasons.PrecheckBadMessage(input_api, |
| 20 | output_api, histogram_name)) |
| 21 | |
| 22 | import presubmit_scheme_histograms |
| 23 | results.extend(presubmit_scheme_histograms. |
| 24 | PrecheckShouldAllowOpenURLEnums(input_api, output_api)) |
| 25 | |
| 26 | return results |
dougt | b53dc59 | 2017-02-01 16:25:00 | [diff] [blame] | 27 | except: |
| 28 | return [output_api.PresubmitError('Could not verify histogram!')] |
| 29 | finally: |
| 30 | sys.path = original_sys_path |
| 31 | |
[email protected] | 54caefd | 2012-02-15 06:18:56 | [diff] [blame] | 32 | |
| 33 | def _CommonChecks(input_api, output_api): |
| 34 | """Checks common to both upload and commit.""" |
dbeam | ccf7fef | 2017-05-17 22:24:29 | [diff] [blame] | 35 | return _RunHistogramChecks(input_api, output_api, "BadMessageReasonChrome") |
[email protected] | 54caefd | 2012-02-15 06:18:56 | [diff] [blame] | 36 | |
[email protected] | 516dce2 | 2014-05-01 18:31:53 | [diff] [blame] | 37 | |
dbeam | ccf7fef | 2017-05-17 22:24:29 | [diff] [blame] | 38 | def CheckChangeOnUpload(input_api, output_api): |
| 39 | return _CommonChecks(input_api, output_api) |
dbeam | a7b29129 | 2015-07-20 21:53:48 | [diff] [blame] | 40 | |
dbeam | a7b29129 | 2015-07-20 21:53:48 | [diff] [blame] | 41 | |
dbeam | ccf7fef | 2017-05-17 22:24:29 | [diff] [blame] | 42 | def CheckChangeOnCommit(input_api, output_api): |
| 43 | return _CommonChecks(input_api, output_api) |