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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 import warnings | 593 import warnings |
594 warnings.filterwarnings('ignore', category=DeprecationWarning) | 594 warnings.filterwarnings('ignore', category=DeprecationWarning) |
595 try: | 595 try: |
596 files = _FetchAllFiles(input_api, white_list, black_list) | 596 files = _FetchAllFiles(input_api, white_list, black_list) |
597 if not files: | 597 if not files: |
598 return [] | 598 return [] |
599 # Now that at least one python file was modified and all the python files | 599 # Now that at least one python file was modified and all the python files |
600 # were listed, try to run pylint. | 600 # were listed, try to run pylint. |
601 try: | 601 try: |
602 from pylint import lint | 602 from pylint import lint |
| 603 input_api.logging.debug( |
| 604 'Using pylint v%s from %s' % (lint.version, lint.__file__)) |
603 except ImportError: | 605 except ImportError: |
604 if input_api.platform == 'win32': | 606 if input_api.platform == 'win32': |
605 return [output_api.PresubmitNotifyResult( | 607 return [output_api.PresubmitNotifyResult( |
606 'Warning: Can\'t run pylint because it is not installed. Please ' | 608 'Warning: Can\'t run pylint because it is not installed. Please ' |
607 'install manually\n' | 609 'install manually\n' |
608 'Cannot do static analysis of python files.')] | 610 'Cannot do static analysis of python files.')] |
609 return [output_api.PresubmitError( | 611 return [output_api.PresubmitError( |
610 'Please install pylint with "sudo apt-get install python-setuptools; ' | 612 'Please install pylint with "sudo apt-get install python-setuptools; ' |
611 'sudo easy_install pylint"\n' | 613 'sudo easy_install pylint"\n' |
612 'or visit http://pypi.python.org/pypi/setuptools.\n' | 614 'or visit http://pypi.python.org/pypi/setuptools.\n' |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( | 910 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( |
909 input_api, output_api, source_file_filter=text_files)) | 911 input_api, output_api, source_file_filter=text_files)) |
910 snapshot("checking svn mime types") | 912 snapshot("checking svn mime types") |
911 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 913 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
912 input_api, output_api)) | 914 input_api, output_api)) |
913 snapshot("checking license") | 915 snapshot("checking license") |
914 results.extend(input_api.canned_checks.CheckLicense( | 916 results.extend(input_api.canned_checks.CheckLicense( |
915 input_api, output_api, license_header, source_file_filter=sources)) | 917 input_api, output_api, license_header, source_file_filter=sources)) |
916 snapshot("done") | 918 snapshot("done") |
917 return results | 919 return results |
OLD | NEW |