OLD | NEW |
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Generic presubmit checks that can be reused by other presubmit checks.""" | 5 """Generic presubmit checks that can be reused by other presubmit checks.""" |
6 | 6 |
7 ### Description checks | 7 ### Description checks |
8 | 8 |
9 def CheckChangeHasTestField(input_api, output_api): | 9 def CheckChangeHasTestField(input_api, output_api): |
10 """Requires that the changelist have a TEST= field.""" | 10 """Requires that the changelist have a TEST= field.""" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 outputs.append(output_api.PresubmitPromptWarning( | 206 outputs.append(output_api.PresubmitPromptWarning( |
207 'These files should end in one (and only one) newline character:', | 207 'These files should end in one (and only one) newline character:', |
208 items=eof_files)) | 208 items=eof_files)) |
209 return outputs | 209 return outputs |
210 | 210 |
211 | 211 |
212 def CheckChangeHasNoTabs(input_api, output_api, source_file_filter=None): | 212 def CheckChangeHasNoTabs(input_api, output_api, source_file_filter=None): |
213 """Checks that there are no tab characters in any of the text files to be | 213 """Checks that there are no tab characters in any of the text files to be |
214 submitted. | 214 submitted. |
215 """ | 215 """ |
| 216 # In addition to the filter, make sure that makefiles are blacklisted. |
| 217 if not source_file_filter: |
| 218 # It's the default filter. |
| 219 source_file_filter = input_api.FilterSourceFile |
| 220 def filter_more(affected_file): |
| 221 return (not input_api.os_path.basename(affected_file.LocalPath()) in |
| 222 ('Makefile', 'makefile') and |
| 223 source_file_filter(affected_file)) |
216 tabs = [] | 224 tabs = [] |
217 for f, line_num, line in input_api.RightHandSideLines(source_file_filter): | 225 for f, line_num, line in input_api.RightHandSideLines(filter_more): |
218 if '\t' in line: | 226 if '\t' in line: |
219 tabs.append('%s, line %s' % (f.LocalPath(), line_num)) | 227 tabs.append('%s, line %s' % (f.LocalPath(), line_num)) |
220 if tabs: | 228 if tabs: |
221 return [output_api.PresubmitPromptWarning('Found a tab character in:', | 229 return [output_api.PresubmitPromptWarning('Found a tab character in:', |
222 long_text='\n'.join(tabs))] | 230 long_text='\n'.join(tabs))] |
223 return [] | 231 return [] |
224 | 232 |
225 | 233 |
226 def CheckChangeHasNoStrayWhitespace(input_api, output_api, | 234 def CheckChangeHasNoStrayWhitespace(input_api, output_api, |
227 source_file_filter=None): | 235 source_file_filter=None): |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 pending_builds_len = len(builder.get('pending_builds', [])) | 496 pending_builds_len = len(builder.get('pending_builds', [])) |
489 if pending_builds_len > max_pendings: | 497 if pending_builds_len > max_pendings: |
490 out.append('%s has %d build(s) pending' % | 498 out.append('%s has %d build(s) pending' % |
491 (builder_name, pending_builds_len)) | 499 (builder_name, pending_builds_len)) |
492 if out: | 500 if out: |
493 return [output_api.PresubmitPromptWarning( | 501 return [output_api.PresubmitPromptWarning( |
494 'Build(s) pending. It is suggested to wait that no more than %d ' | 502 'Build(s) pending. It is suggested to wait that no more than %d ' |
495 'builds are pending.' % max_pendings, | 503 'builds are pending.' % max_pendings, |
496 long_text='\n'.join(out))] | 504 long_text='\n'.join(out))] |
497 return [] | 505 return [] |
OLD | NEW |