| 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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 approvers = [] | 717 approvers = [] |
| 718 for m in messages: | 718 for m in messages: |
| 719 sender = m['sender'] | 719 sender = m['sender'] |
| 720 if _IsApprovingComment(m['text']) and match_reviewer(sender): | 720 if _IsApprovingComment(m['text']) and match_reviewer(sender): |
| 721 approvers.append(sender) | 721 approvers.append(sender) |
| 722 return set(approvers) | 722 return set(approvers) |
| 723 | 723 |
| 724 | 724 |
| 725 def _CheckConstNSObject(input_api, output_api, source_file_filter): | 725 def _CheckConstNSObject(input_api, output_api, source_file_filter): |
| 726 """Checks to make sure no objective-c files have |const NSSomeClass*|.""" | 726 """Checks to make sure no objective-c files have |const NSSomeClass*|.""" |
| 727 pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') | 727 pattern = input_api.re.compile( |
| 728 r'const\s+NS(?!(Point|Range|Rect|Size)\s*\*)\w*\s*\*') |
| 728 | 729 |
| 729 def objective_c_filter(f): | 730 def objective_c_filter(f): |
| 730 return (source_file_filter(f) and | 731 return (source_file_filter(f) and |
| 731 input_api.os_path.splitext(f.LocalPath())[1] in ('.h', '.mm')) | 732 input_api.os_path.splitext(f.LocalPath())[1] in ('.h', '.m', '.mm')) |
| 732 | 733 |
| 733 files = [] | 734 files = [] |
| 734 for f in input_api.AffectedSourceFiles(objective_c_filter): | 735 for f in input_api.AffectedSourceFiles(objective_c_filter): |
| 735 contents = input_api.ReadFile(f) | 736 contents = input_api.ReadFile(f) |
| 736 if pattern.search(contents): | 737 if pattern.search(contents): |
| 737 files.append(f) | 738 files.append(f) |
| 738 | 739 |
| 739 if files: | 740 if files: |
| 740 if input_api.is_committing: | 741 if input_api.is_committing: |
| 741 res_type = output_api.PresubmitPromptWarning | 742 res_type = output_api.PresubmitPromptWarning |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 input_api, output_api, source_file_filter=text_files)) | 829 input_api, output_api, source_file_filter=text_files)) |
| 829 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 830 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
| 830 input_api, output_api)) | 831 input_api, output_api)) |
| 831 results.extend(input_api.canned_checks.CheckLicense( | 832 results.extend(input_api.canned_checks.CheckLicense( |
| 832 input_api, output_api, license_header, source_file_filter=sources)) | 833 input_api, output_api, license_header, source_file_filter=sources)) |
| 833 results.extend(_CheckConstNSObject( | 834 results.extend(_CheckConstNSObject( |
| 834 input_api, output_api, source_file_filter=sources)) | 835 input_api, output_api, source_file_filter=sources)) |
| 835 results.extend(_CheckSingletonInHeaders( | 836 results.extend(_CheckSingletonInHeaders( |
| 836 input_api, output_api, source_file_filter=sources)) | 837 input_api, output_api, source_file_filter=sources)) |
| 837 return results | 838 return results |
| OLD | NEW |