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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 tabs.append('%s, line %s' % (f.LocalPath(), line_num)) | 230 tabs.append('%s, line %s' % (f.LocalPath(), line_num)) |
231 if tabs: | 231 if tabs: |
232 return [output_api.PresubmitPromptWarning('Found a tab character in:', | 232 return [output_api.PresubmitPromptWarning('Found a tab character in:', |
233 long_text='\n'.join(tabs))] | 233 long_text='\n'.join(tabs))] |
234 return [] | 234 return [] |
235 | 235 |
236 | 236 |
237 def CheckChangeTodoHasOwner(input_api, output_api, source_file_filter=None): | 237 def CheckChangeTodoHasOwner(input_api, output_api, source_file_filter=None): |
238 """Checks that the user didn't add TODO(name) without an owner.""" | 238 """Checks that the user didn't add TODO(name) without an owner.""" |
239 | 239 |
240 unowned_todo = input_api.re.compile('TO' + 'DO[^(]'); | 240 unowned_todo = input_api.re.compile('TO' + 'DO[^(]') |
241 for f, line_num, line in input_api.RightHandSideLines(source_file_filter): | 241 for f, line_num, line in input_api.RightHandSideLines(source_file_filter): |
242 if unowned_todo.search(line): | 242 if unowned_todo.search(line): |
243 text = ('Found TO' + 'DO with no owner in %s, line %s' % | 243 text = ('Found TO' + 'DO with no owner in %s, line %s' % |
244 (f.LocalPath(), line_num)) | 244 (f.LocalPath(), line_num)) |
245 return [output_api.PresubmitPromptWarning(text)] | 245 return [output_api.PresubmitPromptWarning(text)] |
246 return [] | 246 return [] |
247 | 247 |
248 | 248 |
249 def CheckChangeHasNoStrayWhitespace(input_api, output_api, | 249 def CheckChangeHasNoStrayWhitespace(input_api, output_api, |
250 source_file_filter=None): | 250 source_file_filter=None): |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 pending_builds_len = len(builder.get('pending_builds', [])) | 617 pending_builds_len = len(builder.get('pending_builds', [])) |
618 if pending_builds_len > max_pendings: | 618 if pending_builds_len > max_pendings: |
619 out.append('%s has %d build(s) pending' % | 619 out.append('%s has %d build(s) pending' % |
620 (builder_name, pending_builds_len)) | 620 (builder_name, pending_builds_len)) |
621 if out: | 621 if out: |
622 return [output_api.PresubmitPromptWarning( | 622 return [output_api.PresubmitPromptWarning( |
623 'Build(s) pending. It is suggested to wait that no more than %d ' | 623 'Build(s) pending. It is suggested to wait that no more than %d ' |
624 'builds are pending.' % max_pendings, | 624 'builds are pending.' % max_pendings, |
625 long_text='\n'.join(out))] | 625 long_text='\n'.join(out))] |
626 return [] | 626 return [] |
OLD | NEW |