| OLD | NEW | 
|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import os as _os | 7 import os as _os | 
| 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) | 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) | 
| 9 | 9 | 
| 10 | 10 | 
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 636   extra_paths_list = extra_paths_list or [] | 636   extra_paths_list = extra_paths_list or [] | 
| 637 | 637 | 
| 638   if input_api.is_committing: | 638   if input_api.is_committing: | 
| 639     error_type = output_api.PresubmitError | 639     error_type = output_api.PresubmitError | 
| 640   else: | 640   else: | 
| 641     error_type = output_api.PresubmitPromptWarning | 641     error_type = output_api.PresubmitPromptWarning | 
| 642 | 642 | 
| 643   # Only trigger if there is at least one python file affected. | 643   # Only trigger if there is at least one python file affected. | 
| 644   def rel_path(regex): | 644   def rel_path(regex): | 
| 645     """Modifies a regex for a subject to accept paths relative to root.""" | 645     """Modifies a regex for a subject to accept paths relative to root.""" | 
| 646     if input_api.os_path.samefile( | 646     def samefile(a, b): | 
| 647         input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()): | 647       # Default implementation for platforms lacking os.path.samefile | 
|  | 648       # (like Windows). | 
|  | 649       return input_api.os_path.abspath(a) == input_api.os_path.abspath(b) | 
|  | 650     samefile = getattr(input_api.os_path, 'samefile', samefile) | 
|  | 651     if samefile(input_api.PresubmitLocalPath(), | 
|  | 652                 input_api.change.RepositoryRoot()): | 
| 648       return regex | 653       return regex | 
|  | 654 | 
| 649     prefix = input_api.os_path.join(input_api.os_path.relpath( | 655     prefix = input_api.os_path.join(input_api.os_path.relpath( | 
| 650         input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), '') | 656         input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), '') | 
| 651     return input_api.re.escape(prefix) + regex | 657     return input_api.re.escape(prefix) + regex | 
| 652   src_filter = lambda x: input_api.FilterSourceFile( | 658   src_filter = lambda x: input_api.FilterSourceFile( | 
| 653       x, map(rel_path, white_list), map(rel_path, black_list)) | 659       x, map(rel_path, white_list), map(rel_path, black_list)) | 
| 654   if not input_api.AffectedSourceFiles(src_filter): | 660   if not input_api.AffectedSourceFiles(src_filter): | 
| 655     input_api.logging.info('Skipping pylint: no matching changes.') | 661     input_api.logging.info('Skipping pylint: no matching changes.') | 
| 656     return [] | 662     return [] | 
| 657 | 663 | 
| 658   extra_args = ['--rcfile=%s' % input_api.os_path.join(_HERE, 'pylintrc')] | 664   extra_args = ['--rcfile=%s' % input_api.os_path.join(_HERE, 'pylintrc')] | 
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 999     snapshot("checking description") | 1005     snapshot("checking description") | 
| 1000     results.extend(input_api.canned_checks.CheckChangeHasDescription( | 1006     results.extend(input_api.canned_checks.CheckChangeHasDescription( | 
| 1001         input_api, output_api)) | 1007         input_api, output_api)) | 
| 1002     results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( | 1008     results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( | 
| 1003         input_api, output_api)) | 1009         input_api, output_api)) | 
| 1004     snapshot("checking do not submit in files") | 1010     snapshot("checking do not submit in files") | 
| 1005     results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( | 1011     results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( | 
| 1006         input_api, output_api)) | 1012         input_api, output_api)) | 
| 1007   snapshot("done") | 1013   snapshot("done") | 
| 1008   return results | 1014   return results | 
| OLD | NEW | 
|---|