Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: presubmit_canned_checks.py

Issue 851103004: Remove the 'author_counts_as_owner' option from CheckOwners(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 out.append('%s has %d build(s) pending' % 840 out.append('%s has %d build(s) pending' %
841 (builder_name, pending_builds_len)) 841 (builder_name, pending_builds_len))
842 if out: 842 if out:
843 return [output_api.PresubmitPromptWarning( 843 return [output_api.PresubmitPromptWarning(
844 'Build(s) pending. It is suggested to wait that no more than %d ' 844 'Build(s) pending. It is suggested to wait that no more than %d '
845 'builds are pending.' % max_pendings, 845 'builds are pending.' % max_pendings,
846 long_text='\n'.join(out))] 846 long_text='\n'.join(out))]
847 return [] 847 return []
848 848
849 849
850 def CheckOwners(input_api, output_api, source_file_filter=None, 850 def CheckOwners(input_api, output_api, source_file_filter=None):
851 author_counts_as_owner=True):
852 if input_api.is_committing: 851 if input_api.is_committing:
853 if input_api.tbr: 852 if input_api.tbr:
854 return [output_api.PresubmitNotifyResult( 853 return [output_api.PresubmitNotifyResult(
855 '--tbr was specified, skipping OWNERS check')] 854 '--tbr was specified, skipping OWNERS check')]
856 if not input_api.change.issue: 855 if not input_api.change.issue:
857 return [output_api.PresubmitError("OWNERS check failed: this change has " 856 return [output_api.PresubmitError("OWNERS check failed: this change has "
858 "no Rietveld issue number, so we can't check it for approvals.")] 857 "no Rietveld issue number, so we can't check it for approvals.")]
859 needed = 'LGTM from an OWNER' 858 needed = 'LGTM from an OWNER'
860 output = output_api.PresubmitError 859 output = output_api.PresubmitError
861 else: 860 else:
862 needed = 'OWNER reviewers' 861 needed = 'OWNER reviewers'
863 output = output_api.PresubmitNotifyResult 862 output = output_api.PresubmitNotifyResult
864 863
865 affected_files = set([f.LocalPath() for f in 864 affected_files = set([f.LocalPath() for f in
866 input_api.change.AffectedFiles(file_filter=source_file_filter)]) 865 input_api.change.AffectedFiles(file_filter=source_file_filter)])
867 866
868 owners_db = input_api.owners_db 867 owners_db = input_api.owners_db
869 owner_email, reviewers = _RietveldOwnerAndReviewers( 868 owner_email, reviewers = _RietveldOwnerAndReviewers(
870 input_api, 869 input_api,
871 owners_db.email_regexp, 870 owners_db.email_regexp,
872 approval_needed=input_api.is_committing) 871 approval_needed=input_api.is_committing)
873 872
874 owner_email = owner_email or input_api.change.author_email 873 owner_email = owner_email or input_api.change.author_email
875 874
876 if author_counts_as_owner and owner_email: 875 if owner_email:
877 reviewers_plus_owner = set([owner_email]).union(reviewers) 876 reviewers_plus_owner = set([owner_email]).union(reviewers)
878 missing_files = owners_db.files_not_covered_by(affected_files, 877 missing_files = owners_db.files_not_covered_by(affected_files,
879 reviewers_plus_owner) 878 reviewers_plus_owner)
880 else: 879 else:
881 missing_files = owners_db.files_not_covered_by(affected_files, reviewers) 880 missing_files = owners_db.files_not_covered_by(affected_files, reviewers)
882 881
883 if missing_files: 882 if missing_files:
884 output_list = [ 883 output_list = [
885 output('Missing %s for these files:\n %s' % 884 output('Missing %s for these files:\n %s' %
886 (needed, '\n '.join(sorted(missing_files))))] 885 (needed, '\n '.join(sorted(missing_files))))]
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 for f in affected_files: 1134 for f in affected_files:
1136 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1135 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1137 rc = gn.main(cmd) 1136 rc = gn.main(cmd)
1138 if rc == 2: 1137 if rc == 2:
1139 warnings.append(output_api.PresubmitPromptWarning( 1138 warnings.append(output_api.PresubmitPromptWarning(
1140 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1139 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1141 f.AbsoluteLocalPath(), f.LocalPath()))) 1140 f.AbsoluteLocalPath(), f.LocalPath())))
1142 # It's just a warning, so ignore other types of failures assuming they'll be 1141 # It's just a warning, so ignore other types of failures assuming they'll be
1143 # caught elsewhere. 1142 # caught elsewhere.
1144 return warnings 1143 return warnings
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698