Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: presubmit_canned_checks.py

Issue 2814017: Makefiles will always contain tabs so make the notab check filter them out. (Closed)
Patch Set: Use basename() instead Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 []
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698