Chromium Code Reviews| 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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 suggested_owners = owners_db.reviewers_for(affected_files) | 784 suggested_owners = owners_db.reviewers_for(affected_files) |
| 785 output_list.append(output('Suggested OWNERS:\n %s' % | 785 output_list.append(output('Suggested OWNERS:\n %s' % |
| 786 ('\n '.join(suggested_owners)))) | 786 ('\n '.join(suggested_owners)))) |
| 787 return output_list | 787 return output_list |
| 788 | 788 |
| 789 if input_api.is_committing and not reviewers: | 789 if input_api.is_committing and not reviewers: |
| 790 return [output('Missing LGTM from someone other than %s' % owner_email)] | 790 return [output('Missing LGTM from someone other than %s' % owner_email)] |
| 791 return [] | 791 return [] |
| 792 | 792 |
| 793 | 793 |
| 794 def CheckIssueNotClosed(input_api, output_api): | |
| 795 """Verify issue is not closed. | |
| 796 | |
| 797 We should not be working with a closed review. CQ and dcommit set this bit, | |
| 798 so it is a pretty good indicator of whether an issue has been committed. | |
| 799 """ | |
| 800 | |
| 801 issue = input_api.change.issue | |
| 802 if issue: | |
| 803 issue_props = input_api.rietveld.get_issue_properties( | |
|
M-A Ruel
2012/11/19 13:04:01
input_api.rietveld could be None in the case it's
Isaac (away)
2012/11/21 20:24:32
Done, added to _GetRietveldIssueProps in latest pa
| |
| 804 issue=int(issue), messages=False) | |
|
M-A Ruel
2012/11/19 13:04:01
Is the int() call necessary? If so, it's a bug in
Isaac (away)
2012/11/21 20:24:32
It was required, fixed in latest patchset.
| |
| 805 if issue_props['closed']: | |
| 806 return [output_api.PresubmitError( | |
| 807 'Issue %s is closed. If this issue was already used for a commit,\n' | |
| 808 'please reset the issue number associated with this branch with:\n' | |
| 809 'git cl issue 0\n' % issue | |
| 810 )] | |
| 811 return [] | |
| 812 | |
|
M-A Ruel
2012/11/19 13:04:01
2 lines
Isaac (away)
2012/11/21 20:24:32
Done.
| |
| 794 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): | 813 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): |
| 795 """Return the owner and reviewers of a change, if any. | 814 """Return the owner and reviewers of a change, if any. |
| 796 | 815 |
| 797 If approval_needed is True, only reviewers who have approved the change | 816 If approval_needed is True, only reviewers who have approved the change |
| 798 will be returned. | 817 will be returned. |
| 799 """ | 818 """ |
| 800 if not input_api.change.issue: | 819 if not input_api.change.issue: |
| 801 return None, None | 820 return None, None |
| 802 | 821 |
| 803 issue_props = input_api.rietveld.get_issue_properties( | 822 issue_props = input_api.rietveld.get_issue_properties( |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 delta_ms = int(1000*(dt2 - snapshot_memory[0])) | 952 delta_ms = int(1000*(dt2 - snapshot_memory[0])) |
| 934 if delta_ms > 500: | 953 if delta_ms > 500: |
| 935 print " %s took a long time: %dms" % (snapshot_memory[1], delta_ms) | 954 print " %s took a long time: %dms" % (snapshot_memory[1], delta_ms) |
| 936 snapshot_memory[:] = (dt2, msg) | 955 snapshot_memory[:] = (dt2, msg) |
| 937 | 956 |
| 938 if owners_check: | 957 if owners_check: |
| 939 snapshot("checking owners") | 958 snapshot("checking owners") |
| 940 results.extend(input_api.canned_checks.CheckOwners( | 959 results.extend(input_api.canned_checks.CheckOwners( |
| 941 input_api, output_api, source_file_filter=None)) | 960 input_api, output_api, source_file_filter=None)) |
| 942 | 961 |
| 962 snapshot("checking review not closed") | |
| 963 results.extend(input_api.canned_checks.CheckIssueNotClosed( | |
| 964 input_api, output_api)) | |
| 965 | |
| 943 snapshot("checking long lines") | 966 snapshot("checking long lines") |
| 944 results.extend(input_api.canned_checks.CheckLongLines( | 967 results.extend(input_api.canned_checks.CheckLongLines( |
| 945 input_api, output_api, source_file_filter=sources)) | 968 input_api, output_api, source_file_filter=sources)) |
| 946 snapshot( "checking tabs") | 969 snapshot( "checking tabs") |
| 947 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( | 970 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( |
| 948 input_api, output_api, source_file_filter=sources)) | 971 input_api, output_api, source_file_filter=sources)) |
| 949 snapshot( "checking stray whitespace") | 972 snapshot( "checking stray whitespace") |
| 950 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 973 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
| 951 input_api, output_api, source_file_filter=sources)) | 974 input_api, output_api, source_file_filter=sources)) |
| 952 snapshot("checking nsobjects") | 975 snapshot("checking nsobjects") |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 966 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 989 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
| 967 input_api, output_api)) | 990 input_api, output_api)) |
| 968 snapshot("checking license") | 991 snapshot("checking license") |
| 969 results.extend(input_api.canned_checks.CheckLicense( | 992 results.extend(input_api.canned_checks.CheckLicense( |
| 970 input_api, output_api, license_header, source_file_filter=sources)) | 993 input_api, output_api, license_header, source_file_filter=sources)) |
| 971 snapshot("checking was uploaded") | 994 snapshot("checking was uploaded") |
| 972 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 995 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
| 973 input_api, output_api)) | 996 input_api, output_api)) |
| 974 snapshot("done") | 997 snapshot("done") |
| 975 return results | 998 return results |
| OLD | NEW |