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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 | 786 |
787 affected_files = set([f.LocalPath() for f in | 787 affected_files = set([f.LocalPath() for f in |
788 input_api.change.AffectedFiles(file_filter=source_file_filter)]) | 788 input_api.change.AffectedFiles(file_filter=source_file_filter)]) |
789 | 789 |
790 owners_db = input_api.owners_db | 790 owners_db = input_api.owners_db |
791 owner_email, reviewers = _RietveldOwnerAndReviewers( | 791 owner_email, reviewers = _RietveldOwnerAndReviewers( |
792 input_api, | 792 input_api, |
793 owners_db.email_regexp, | 793 owners_db.email_regexp, |
794 approval_needed=input_api.is_committing) | 794 approval_needed=input_api.is_committing) |
795 | 795 |
796 if author_counts_as_owner: | 796 owner_email = owner_email or input_api.change.author_email |
797 if owner_email: | 797 |
798 message = '' | 798 if author_counts_as_owner and owner_email: |
799 reviewers_plus_owner = reviewers.union(set([owner_email])) | 799 reviewers_plus_owner = set([owner_email]).union(reviewers or set()) |
800 else: | |
801 message = ('\nUntil the issue is uploaded, this list will include ' | |
802 'files for which you are an OWNER.') | |
803 owner_email = '' | |
804 reviewers_plus_owner = set() | |
805 missing_files = owners_db.files_not_covered_by(affected_files, | 800 missing_files = owners_db.files_not_covered_by(affected_files, |
806 reviewers_plus_owner) | 801 reviewers_plus_owner) |
807 else: | 802 else: |
808 message = '' | |
809 missing_files = owners_db.files_not_covered_by(affected_files, reviewers) | 803 missing_files = owners_db.files_not_covered_by(affected_files, reviewers) |
810 | 804 |
811 if missing_files: | 805 if missing_files: |
812 output_list = [ | 806 output_list = [ |
813 output('Missing %s for these files:\n %s%s' % | 807 output('Missing %s for these files:\n %s' % |
814 (needed, '\n '.join(missing_files), message))] | 808 (needed, '\n '.join(missing_files)))] |
815 if not input_api.is_committing: | 809 if not input_api.is_committing: |
816 suggested_owners = owners_db.reviewers_for(affected_files, owner_email) | 810 suggested_owners = owners_db.reviewers_for(affected_files, owner_email) |
817 output_list.append(output('Suggested OWNERS:\n %s' % | 811 output_list.append(output('Suggested OWNERS:\n %s' % |
818 ('\n '.join(suggested_owners or [])))) | 812 ('\n '.join(suggested_owners or [])))) |
819 return output_list | 813 return output_list |
820 | 814 |
821 if input_api.is_committing and not reviewers: | 815 if input_api.is_committing and not reviewers: |
822 return [output('Missing LGTM from someone other than %s' % owner_email)] | 816 return [output('Missing LGTM from someone other than %s' % owner_email)] |
823 return [] | 817 return [] |
824 | 818 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 snapshot("checking description") | 1007 snapshot("checking description") |
1014 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 1008 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
1015 input_api, output_api)) | 1009 input_api, output_api)) |
1016 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( | 1010 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( |
1017 input_api, output_api)) | 1011 input_api, output_api)) |
1018 snapshot("checking do not submit in files") | 1012 snapshot("checking do not submit in files") |
1019 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( | 1013 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( |
1020 input_api, output_api)) | 1014 input_api, output_api)) |
1021 snapshot("done") | 1015 snapshot("done") |
1022 return results | 1016 return results |
OLD | NEW |