blob: bcf853c2b0eadb8495f608cd5fbbb546deb7032c [file] [log] [blame]
Dale Curtis3c16ae02018-10-31 13:02:29 -07001# Copyright 2018 The Chromium 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"""Presubmit script for nasm repository."""
5
6
7def _WarnIfGitIgnoreHasSources(input_api, output_api):
8 """Warn if .gitignore has source files in it."""
9 for f in input_api.AffectedFiles():
10 if f.LocalPath().endswith('.gitignore'):
11 with open(f.LocalPath(), 'r') as f:
12 lines = f.readlines()
13
14 bad_lines = [l.strip() for l in lines if l.strip().endswith(('.c', '.h'))]
15 if not bad_lines:
16 break
17
18 return [
19 output_api.PresubmitError('\n'.join([
20 '.gitignore contains source files which may be needed for building, ',
21 'please remove the .gitignore entries for the following lines:',
22 '\n ' + ' \n'.join(bad_lines)
23 ]))
24 ]
25 return []
26
27
28def CheckChangeOnUpload(input_api, output_api):
29 results = []
30 results.extend(_WarnIfGitIgnoreHasSources(input_api, output_api))
31 return results