blob: b6abea3cc5eb5d4929dc77e93543c7324abbf811 [file] [log] [blame]
Avi Drissmanea62cfa2023-01-24 14:57:29 -05001# Copyright 2018 The Chromium Authors
Dale Curtis3c16ae02018-10-31 13:02:29 -07002# 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 Gans7c4113b2022-09-16 15:02:52 -07006USE_PYTHON3 = True
7
Dale Curtis3c16ae02018-10-31 13:02:29 -07008
9def _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
30def CheckChangeOnUpload(input_api, output_api):
31 results = []
32 results.extend(_WarnIfGitIgnoreHasSources(input_api, output_api))
33 return results