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 # Justifications for each filter: | 10 # Justifications for each filter: |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 long_text='\n'.join(out))] | 852 long_text='\n'.join(out))] |
853 return [] | 853 return [] |
854 | 854 |
855 | 855 |
856 def CheckOwners(input_api, output_api, source_file_filter=None): | 856 def CheckOwners(input_api, output_api, source_file_filter=None): |
857 if input_api.is_committing: | 857 if input_api.is_committing: |
858 if input_api.tbr: | 858 if input_api.tbr: |
859 return [output_api.PresubmitNotifyResult( | 859 return [output_api.PresubmitNotifyResult( |
860 '--tbr was specified, skipping OWNERS check')] | 860 '--tbr was specified, skipping OWNERS check')] |
861 if input_api.change.issue: | 861 if input_api.change.issue: |
862 if _GetRietveldIssueProps(input_api, None).get('cq_dry_run', False): | 862 if (input_api.dry_run or |
| 863 # TODO(tandrii): clean below once CQ && run_presubmit.py recipe specify |
| 864 # dry_run property. http://crbug.com/605563. |
| 865 _GetRietveldIssueProps(input_api, None).get('cq_dry_run', False)): |
863 return [output_api.PresubmitNotifyResult( | 866 return [output_api.PresubmitNotifyResult( |
864 'This is a CQ dry run, skipping OWNERS check')] | 867 'This is a dry run, skipping OWNERS check')] |
865 else: | 868 else: |
866 return [output_api.PresubmitError("OWNERS check failed: this change has " | 869 return [output_api.PresubmitError("OWNERS check failed: this change has " |
867 "no Rietveld issue number, so we can't check it for approvals.")] | 870 "no Rietveld issue number, so we can't check it for approvals.")] |
868 needed = 'LGTM from an OWNER' | 871 needed = 'LGTM from an OWNER' |
869 output = output_api.PresubmitError | 872 output = output_api.PresubmitError |
870 else: | 873 else: |
871 needed = 'OWNER reviewers' | 874 needed = 'OWNER reviewers' |
872 output = output_api.PresubmitNotifyResult | 875 output = output_api.PresubmitNotifyResult |
873 | 876 |
874 affected_files = set([f.LocalPath() for f in | 877 affected_files = set([f.LocalPath() for f in |
875 input_api.change.AffectedFiles(file_filter=source_file_filter)]) | 878 input_api.change.AffectedFiles(file_filter=source_file_filter)]) |
876 | 879 |
877 owners_db = input_api.owners_db | 880 owners_db = input_api.owners_db |
| 881 # TODO(tandrii): this will always return None, set() in case of Gerrit. |
878 owner_email, reviewers = _RietveldOwnerAndReviewers( | 882 owner_email, reviewers = _RietveldOwnerAndReviewers( |
879 input_api, | 883 input_api, |
880 owners_db.email_regexp, | 884 owners_db.email_regexp, |
881 approval_needed=input_api.is_committing) | 885 approval_needed=input_api.is_committing) |
882 | 886 |
883 owner_email = owner_email or input_api.change.author_email | 887 owner_email = owner_email or input_api.change.author_email |
884 | 888 |
885 if owner_email: | 889 if owner_email: |
886 reviewers_plus_owner = set([owner_email]).union(reviewers) | 890 reviewers_plus_owner = set([owner_email]).union(reviewers) |
887 missing_files = owners_db.files_not_covered_by(affected_files, | 891 missing_files = owners_db.files_not_covered_by(affected_files, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 for f in affected_files: | 1131 for f in affected_files: |
1128 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] | 1132 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] |
1129 rc = gn.main(cmd) | 1133 rc = gn.main(cmd) |
1130 if rc == 2: | 1134 if rc == 2: |
1131 warnings.append(output_api.PresubmitPromptWarning( | 1135 warnings.append(output_api.PresubmitPromptWarning( |
1132 '%s requires formatting. Please run `gn format --in-place %s`.' % ( | 1136 '%s requires formatting. Please run `gn format --in-place %s`.' % ( |
1133 f.AbsoluteLocalPath(), f.LocalPath()))) | 1137 f.AbsoluteLocalPath(), f.LocalPath()))) |
1134 # It's just a warning, so ignore other types of failures assuming they'll be | 1138 # It's just a warning, so ignore other types of failures assuming they'll be |
1135 # caught elsewhere. | 1139 # caught elsewhere. |
1136 return warnings | 1140 return warnings |
OLD | NEW |