| 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 | 7 |
| 8 ### Description checks | 8 ### Description checks |
| 9 | 9 |
| 10 def CheckChangeHasTestField(input_api, output_api): | 10 def CheckChangeHasTestField(input_api, output_api): |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 affected_files = set([f.LocalPath() for f in | 745 affected_files = set([f.LocalPath() for f in |
| 746 input_api.change.AffectedFiles(file_filter=source_file_filter)]) | 746 input_api.change.AffectedFiles(file_filter=source_file_filter)]) |
| 747 | 747 |
| 748 owners_db = input_api.owners_db | 748 owners_db = input_api.owners_db |
| 749 owner_email, reviewers = _RietveldOwnerAndReviewers( | 749 owner_email, reviewers = _RietveldOwnerAndReviewers( |
| 750 input_api, | 750 input_api, |
| 751 owners_db.email_regexp, | 751 owners_db.email_regexp, |
| 752 approval_needed=input_api.is_committing) | 752 approval_needed=input_api.is_committing) |
| 753 | 753 |
| 754 if owner_email: | 754 if owner_email: |
| 755 message = '' |
| 755 reviewers_plus_owner = reviewers.union(set([owner_email])) | 756 reviewers_plus_owner = reviewers.union(set([owner_email])) |
| 756 elif input_api.is_committing: | |
| 757 return [output_api.PresubmitWarning( | |
| 758 'The issue was not uploaded so you have no OWNER approval.')] | |
| 759 else: | 757 else: |
| 758 message = ('\nUntil the issue is uploaded, this list will include ' |
| 759 'directories for which you \nare an OWNER.') |
| 760 owner_email = '' | 760 owner_email = '' |
| 761 reviewers_plus_owner = set() | 761 reviewers_plus_owner = set() |
| 762 | 762 |
| 763 missing_directories = owners_db.directories_not_covered_by(affected_files, | 763 missing_directories = owners_db.directories_not_covered_by(affected_files, |
| 764 reviewers_plus_owner) | 764 reviewers_plus_owner) |
| 765 if missing_directories: | 765 if missing_directories: |
| 766 return [output('Missing %s for files in these directories:\n %s' % | 766 return [output('Missing %s for files in these directories:\n %s%s' % |
| 767 (needed, '\n '.join(missing_directories)))] | 767 (needed, '\n '.join(missing_directories), message))] |
| 768 | 768 |
| 769 if input_api.is_committing and not reviewers: | 769 if input_api.is_committing and not reviewers: |
| 770 return [output('Missing LGTM from someone other than %s' % owner_email)] | 770 return [output('Missing LGTM from someone other than %s' % owner_email)] |
| 771 return [] | 771 return [] |
| 772 | 772 |
| 773 | 773 |
| 774 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): | 774 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): |
| 775 """Return the owner and reviewers of a change, if any. | 775 """Return the owner and reviewers of a change, if any. |
| 776 | 776 |
| 777 If approval_needed is True, only reviewers who have approved the change | 777 If approval_needed is True, only reviewers who have approved the change |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 937 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
| 938 input_api, output_api)) | 938 input_api, output_api)) |
| 939 snapshot("checking license") | 939 snapshot("checking license") |
| 940 results.extend(input_api.canned_checks.CheckLicense( | 940 results.extend(input_api.canned_checks.CheckLicense( |
| 941 input_api, output_api, license_header, source_file_filter=sources)) | 941 input_api, output_api, license_header, source_file_filter=sources)) |
| 942 snapshot("checking was uploaded") | 942 snapshot("checking was uploaded") |
| 943 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 943 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
| 944 input_api, output_api)) | 944 input_api, output_api)) |
| 945 snapshot("done") | 945 snapshot("done") |
| 946 return results | 946 return results |
| OLD | NEW |