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( |
| 8 | './generate.sh', |
| 9 | shell=True, |
| 10 | stdout=input_api.subprocess.PIPE, |
| 11 | stderr=input_api.subprocess.PIPE) |
| 12 | if input_api.subprocess.call( |
| 13 | 'git diff --exit-code', |
| 14 | shell=True, |
| 15 | stdout=input_api.subprocess.PIPE, |
| 16 | stderr=input_api.subprocess.PIPE) != 0: |
| 17 | msg = ('Running generate.sh produced a diff. Please ' |
| 18 | 'run the script, amend your changes, and try again.') |
| 19 | results.append(output_api.PresubmitError(msg)) |
| 20 | return results |
| 21 | |
| 22 | def CheckChangeOnUpload(input_api, output_api): |
| 23 | return CheckGenerated(input_api, output_api) |
| 24 | |
| 25 | def CheckChangeOnCommit(input_api, output_api): |
| 26 | return CheckGenerated(input_api, output_api) |