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 | 7 |
8 ### Description checks | 8 ### Description checks |
9 | 9 |
10 def CheckChangeHasTestField(input_api, output_api): | 10 def CheckChangeHasTestField(input_api, output_api): |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 if accept_empty_files and not contents: | 302 if accept_empty_files and not contents: |
303 continue | 303 continue |
304 if not license_re.search(contents): | 304 if not license_re.search(contents): |
305 bad_files.append(f.LocalPath()) | 305 bad_files.append(f.LocalPath()) |
306 if bad_files: | 306 if bad_files: |
307 if input_api.is_committing: | 307 if input_api.is_committing: |
308 res_type = output_api.PresubmitPromptWarning | 308 res_type = output_api.PresubmitPromptWarning |
309 else: | 309 else: |
310 res_type = output_api.PresubmitNotifyResult | 310 res_type = output_api.PresubmitNotifyResult |
311 return [res_type( | 311 return [res_type( |
| 312 'License must match:\n%s\n' % license_re.pattern + |
312 'Found a bad license header in these files:', items=bad_files)] | 313 'Found a bad license header in these files:', items=bad_files)] |
313 return [] | 314 return [] |
314 | 315 |
315 | 316 |
316 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None): | 317 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None): |
317 """Checks that the source files have svn:eol-style=LF.""" | 318 """Checks that the source files have svn:eol-style=LF.""" |
318 return CheckSvnProperty(input_api, output_api, | 319 return CheckSvnProperty(input_api, output_api, |
319 'svn:eol-style', 'LF', | 320 'svn:eol-style', 'LF', |
320 input_api.AffectedSourceFiles(source_file_filter)) | 321 input_api.AffectedSourceFiles(source_file_filter)) |
321 | 322 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 input_api, output_api, source_file_filter=text_files)) | 830 input_api, output_api, source_file_filter=text_files)) |
830 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 831 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
831 input_api, output_api)) | 832 input_api, output_api)) |
832 results.extend(input_api.canned_checks.CheckLicense( | 833 results.extend(input_api.canned_checks.CheckLicense( |
833 input_api, output_api, license_header, source_file_filter=sources)) | 834 input_api, output_api, license_header, source_file_filter=sources)) |
834 results.extend(_CheckConstNSObject( | 835 results.extend(_CheckConstNSObject( |
835 input_api, output_api, source_file_filter=sources)) | 836 input_api, output_api, source_file_filter=sources)) |
836 results.extend(_CheckSingletonInHeaders( | 837 results.extend(_CheckSingletonInHeaders( |
837 input_api, output_api, source_file_filter=sources)) | 838 input_api, output_api, source_file_filter=sources)) |
838 return results | 839 return results |
OLD | NEW |