| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Top-level presubmit script. | 5 """Top-level presubmit script. |
| 6 | 6 |
| 7 See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 7 See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| 8 details on the presubmit API built into depot_tools. | 8 details on the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 pcg = os.path.join(p, exe) | 25 pcg = os.path.join(p, exe) |
| 26 if os.access(pcg, os.X_OK): | 26 if os.access(pcg, os.X_OK): |
| 27 break | 27 break |
| 28 else: | 28 else: |
| 29 return [ | 29 return [ |
| 30 error_type( | 30 error_type( |
| 31 'pre-commit-go executable (pcg) could not be found in PATH. All Go ' | 31 'pre-commit-go executable (pcg) could not be found in PATH. All Go ' |
| 32 'checks are skipped. See https://github.com/maruel/pre-commit-go.') | 32 'checks are skipped. See https://github.com/maruel/pre-commit-go.') |
| 33 ] | 33 ] |
| 34 | 34 |
| 35 # pcg can figure out what files to check on its own based on upstream ref. | |
| 36 cmd = [pcg, 'run', '-m', ','.join(pcg_mode)] | 35 cmd = [pcg, 'run', '-m', ','.join(pcg_mode)] |
| 37 if input_api.verbose: | 36 if input_api.verbose: |
| 38 cmd.append('-v') | 37 cmd.append('-v') |
| 38 # pcg can figure out what files to check on its own based on upstream ref, |
| 39 # but on PRESUBMIT try builder upsteram isn't set, and it's just 1 commit. |
| 40 if os.getenv('PRESUBMIT_BUILDER', ''): |
| 41 cmd.extend(['-r', 'HEAD~1']) |
| 39 return input_api.RunTests([ | 42 return input_api.RunTests([ |
| 40 input_api.Command( | 43 input_api.Command( |
| 41 name='pre-commit-go: %s' % ', '.join(pcg_mode), | 44 name='pre-commit-go: %s' % ', '.join(pcg_mode), |
| 42 cmd=cmd, | 45 cmd=cmd, |
| 43 kwargs={}, | 46 kwargs={}, |
| 44 message=error_type), | 47 message=error_type), |
| 45 ]) | 48 ]) |
| 46 | 49 |
| 47 | 50 |
| 48 def header(input_api): | 51 def header(input_api): |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 results = CommonChecks(input_api, output_api) | 100 results = CommonChecks(input_api, output_api) |
| 98 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 101 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 99 input_api, output_api)) | 102 input_api, output_api)) |
| 100 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( | 103 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( |
| 101 input_api, output_api)) | 104 input_api, output_api)) |
| 102 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( | 105 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( |
| 103 input_api, output_api)) | 106 input_api, output_api)) |
| 104 results.extend(PreCommitGo( | 107 results.extend(PreCommitGo( |
| 105 input_api, output_api, ['lint', 'pre-commit', 'pre-push'])) | 108 input_api, output_api, ['lint', 'pre-commit', 'pre-push'])) |
| 106 return results | 109 return results |
| OLD | NEW |