Avi Drissman | ea62cfa | 2023-01-24 14:57:29 -0500 | [diff] [blame] | 1 | # Copyright 2018 The Chromium Authors |
Dale Curtis | 3c16ae0 | 2018-10-31 13:02:29 -0700 | [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 | """Presubmit script for nasm repository.""" |
| 5 | |
Fabrice de Gans | 7c4113b | 2022-09-16 15:02:52 -0700 | [diff] [blame] | 6 | USE_PYTHON3 = True |
| 7 | |
Dale Curtis | 3c16ae0 | 2018-10-31 13:02:29 -0700 | [diff] [blame] | 8 | |
| 9 | def _WarnIfGitIgnoreHasSources(input_api, output_api): |
| 10 | """Warn if .gitignore has source files in it.""" |
| 11 | for f in input_api.AffectedFiles(): |
| 12 | if f.LocalPath().endswith('.gitignore'): |
| 13 | with open(f.LocalPath(), 'r') as f: |
| 14 | lines = f.readlines() |
| 15 | |
| 16 | bad_lines = [l.strip() for l in lines if l.strip().endswith(('.c', '.h'))] |
| 17 | if not bad_lines: |
| 18 | break |
| 19 | |
| 20 | return [ |
| 21 | output_api.PresubmitError('\n'.join([ |
| 22 | '.gitignore contains source files which may be needed for building, ', |
| 23 | 'please remove the .gitignore entries for the following lines:', |
| 24 | '\n ' + ' \n'.join(bad_lines) |
| 25 | ])) |
| 26 | ] |
| 27 | return [] |
| 28 | |
| 29 | |
| 30 | def CheckChangeOnUpload(input_api, output_api): |
| 31 | results = [] |
| 32 | results.extend(_WarnIfGitIgnoreHasSources(input_api, output_api)) |
| 33 | return results |