David Burger | 9206f8f | 2019-06-20 15:27:22 -0600 | [diff] [blame] | 1 | # Copyright 2019 The Chromium OS 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 | def CheckGenerated(input_api, output_api): |
| 6 | results = [] |
| 7 | input_api.subprocess.call( |
Allen Li | 9854522 | 2020-03-11 14:34:14 -0700 | [diff] [blame] | 8 | ['bash', './generate.sh'], |
David Burger | 9206f8f | 2019-06-20 15:27:22 -0600 | [diff] [blame] | 9 | stdout=input_api.subprocess.PIPE, |
| 10 | stderr=input_api.subprocess.PIPE) |
| 11 | if input_api.subprocess.call( |
Allen Li | 9854522 | 2020-03-11 14:34:14 -0700 | [diff] [blame] | 12 | ['git', 'diff', '--exit-code'], |
David Burger | 9206f8f | 2019-06-20 15:27:22 -0600 | [diff] [blame] | 13 | stdout=input_api.subprocess.PIPE, |
| 14 | stderr=input_api.subprocess.PIPE) != 0: |
| 15 | msg = ('Running generate.sh produced a diff. Please ' |
| 16 | 'run the script, amend your changes, and try again.') |
| 17 | results.append(output_api.PresubmitError(msg)) |
| 18 | return results |
| 19 | |
| 20 | def CheckChangeOnUpload(input_api, output_api): |
| 21 | return CheckGenerated(input_api, output_api) |
| 22 | |
| 23 | def CheckChangeOnCommit(input_api, output_api): |
| 24 | return CheckGenerated(input_api, output_api) |