| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 | 5 |
| 6 def _CommonChecks(input_api, output_api): | 6 def _CommonChecks(input_api, output_api): |
| 7 """Performs common checks, which includes running pylint.""" | 7 """Performs common checks, which includes running pylint.""" |
| 8 results = [] | 8 results = [] |
| 9 | 9 |
| 10 results.extend(_CheckContribDir(input_api, output_api)) | 10 results.extend(_CheckContribDir(input_api, output_api)) |
| 11 return results | 11 return results |
| 12 | 12 |
| 13 | 13 |
| 14 def _CheckOwnershipForContribSubDir(sub_dir, input_api, output_api): | 14 def _CheckOwnershipForContribSubDir(sub_dir, input_api, output_api): |
| 15 results = [] | 15 results = [] |
| 16 owner_file = input_api.os_path.join(sub_dir, 'OWNERS') | 16 owner_file = input_api.os_path.join(sub_dir, 'OWNERS') |
| 17 if not input_api.os_path.isfile(owner_file): | 17 if not input_api.os_path.isfile(owner_file): |
| 18 results.append(output_api.PresubmitError( | 18 results.append(output_api.PresubmitError( |
| 19 '%s must have an OWNERS file' % sub_dir)) | 19 '%s must have an OWNERS file' % sub_dir)) |
| 20 else: | |
| 21 owners = [] | |
| 22 with open(owner_file) as f: | |
| 23 for line in f: | |
| 24 if line.strip() and not line.strip().startswith('#'): | |
| 25 owners.append(line) | |
| 26 if len(owners) < 2: | |
| 27 results.append(output_api.PresubmitError( | |
| 28 '%s must have at least 2 owners' % owner_file)) | |
| 29 return results | 20 return results |
| 30 | 21 |
| 31 | 22 |
| 32 def _CheckContribDir(input_api, output_api): | 23 def _CheckContribDir(input_api, output_api): |
| 33 """ Check to make sure that: | 24 """ Check to make sure that: |
| 34 1) tools/perf/contrib/ contains only directories, except __init__.py, | 25 1) tools/perf/contrib/ contains only directories, except __init__.py, |
| 35 README.md, and PRESUBMIT.py file | 26 README.md, and PRESUBMIT.py file |
| 36 2) Every subdirectory in tools/perf/contrib/ must have an OWNERS file with | 27 2) Every subdirectory in tools/perf/contrib/ must have an OWNERS file with |
| 37 at least two OWNERS. | 28 at least two OWNERS. |
| 38 """ | 29 """ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 66 def CheckChangeOnUpload(input_api, output_api): | 57 def CheckChangeOnUpload(input_api, output_api): |
| 67 report = [] | 58 report = [] |
| 68 report.extend(_CommonChecks(input_api, output_api)) | 59 report.extend(_CommonChecks(input_api, output_api)) |
| 69 return report | 60 return report |
| 70 | 61 |
| 71 | 62 |
| 72 def CheckChangeOnCommit(input_api, output_api): | 63 def CheckChangeOnCommit(input_api, output_api): |
| 73 report = [] | 64 report = [] |
| 74 report.extend(_CommonChecks(input_api, output_api)) | 65 report.extend(_CommonChecks(input_api, output_api)) |
| 75 return report | 66 return report |
| OLD | NEW |