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

Side by Side Diff: presubmit_canned_checks.py

Issue 195793021: Infer CL author and reviewer list from local state if the issue has not previously been uploaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Add an additional test Created 6 years, 9 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
« no previous file with comments | « git_cl.py ('k') | presubmit_support.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 10
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 845
846 846
847 def _GetRietveldIssueProps(input_api, messages): 847 def _GetRietveldIssueProps(input_api, messages):
848 """Gets the issue properties from rietveld.""" 848 """Gets the issue properties from rietveld."""
849 issue = input_api.change.issue 849 issue = input_api.change.issue
850 if issue and input_api.rietveld: 850 if issue and input_api.rietveld:
851 return input_api.rietveld.get_issue_properties( 851 return input_api.rietveld.get_issue_properties(
852 issue=int(issue), messages=messages) 852 issue=int(issue), messages=messages)
853 853
854 854
855 def _ReviewersFromChange(change):
856 """Return the reviewers specified in the |change|, if any."""
857 reviewers = set()
858 if change.R:
859 reviewers.update(set([r.strip() for r in change.R.split(',')]))
860 if change.TBR:
861 reviewers.update(set([r.strip() for r in change.TBR.split(',')]))
862 return reviewers
863
864
855 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): 865 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False):
856 """Return the owner and reviewers of a change, if any. 866 """Return the owner and reviewers of a change, if any.
857 867
858 If approval_needed is True, only reviewers who have approved the change 868 If approval_needed is True, only reviewers who have approved the change
859 will be returned. 869 will be returned.
860 """ 870 """
861 issue_props = _GetRietveldIssueProps(input_api, True) 871 issue_props = _GetRietveldIssueProps(input_api, True)
862 if not issue_props: 872 if not issue_props:
863 return None, set() 873 reviewers = set()
874 if not approval_needed:
875 reviewers = _ReviewersFromChange(input_api.change)
876 return None, reviewers
864 877
865 if not approval_needed: 878 if not approval_needed:
866 return issue_props['owner_email'], set(issue_props['reviewers']) 879 return issue_props['owner_email'], set(issue_props['reviewers'])
867 880
868 owner_email = issue_props['owner_email'] 881 owner_email = issue_props['owner_email']
869 882
870 def match_reviewer(r): 883 def match_reviewer(r):
871 return email_regexp.match(r) and r != owner_email 884 return email_regexp.match(r) and r != owner_email
872 885
873 messages = issue_props.get('messages', []) 886 messages = issue_props.get('messages', [])
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 def CheckPatchFormatted(input_api, output_api): 1059 def CheckPatchFormatted(input_api, output_api):
1047 import git_cl 1060 import git_cl
1048 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] 1061 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()]
1049 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) 1062 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True)
1050 if code == 2: 1063 if code == 2:
1051 return [output_api.PresubmitPromptWarning( 1064 return [output_api.PresubmitPromptWarning(
1052 'Your patch is not formatted, please run git cl format.')] 1065 'Your patch is not formatted, please run git cl format.')]
1053 # As this is just a warning, ignore all other errors if the user 1066 # As this is just a warning, ignore all other errors if the user
1054 # happens to have a broken clang-format, doesn't use git, etc etc. 1067 # happens to have a broken clang-format, doesn't use git, etc etc.
1055 return [] 1068 return []
OLDNEW
« no previous file with comments | « git_cl.py ('k') | presubmit_support.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698