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

Unified Diff: presubmit_canned_checks.py

Issue 1955223002: Properly expose already used elsewhere functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 1e16d8fffba2a70c69c75de569b37e9b8d0edbd7..4ef971ea34f6139fb3c74610f569ce27430fbb46 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -875,7 +875,7 @@ def CheckOwners(input_api, output_api, source_file_filter=None):
input_api.change.AffectedFiles(file_filter=source_file_filter)])
owners_db = input_api.owners_db
- owner_email, reviewers = _CodereviewOwnersAndReviewers(
+ owner_email, reviewers = GetCodereviewOwnerAndReviewers(
input_api,
owners_db.email_regexp,
approval_needed=input_api.is_committing)
@@ -904,25 +904,17 @@ def CheckOwners(input_api, output_api, source_file_filter=None):
return [output('Missing LGTM from someone other than %s' % owner_email)]
return []
-def _CodereviewOwnersAndReviewers(input_api, email_regexp, approval_needed):
+def GetCodereviewOwnerAndReviewers(input_api, email_regexp, approval_needed):
"""Return the owner and reviewers of a change, if any.
If approval_needed is True, only reviewers who have approved the change
will be returned.
"""
- if input_api.change.issue:
- if input_api.gerrit:
- res = _GerritOwnerAndReviewers(input_api, email_regexp, approval_needed)
- else:
- # Rietveld is default.
- res = _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed)
- if res:
- return res
-
- reviewers = set()
- if not approval_needed:
- reviewers = _ReviewersFromChange(input_api.change)
- return None, reviewers
+ # Rietveld is default.
+ func = _RietveldOwnerAndReviewers
+ if input_api.gerrit:
+ func = _GerritOwnerAndReviewers
+ return func(input_api, email_regexp, approval_needed)
def _GetRietveldIssueProps(input_api, messages):
@@ -953,11 +945,11 @@ def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False):
If approval_needed is True, only reviewers who have approved the change
will be returned.
- Returns None if can't fetch issue properties from codereview.
"""
issue_props = _GetRietveldIssueProps(input_api, True)
if not issue_props:
- return None
+ return None, (set() if approval_needed else
+ _ReviewersFromChange(input_api.change))
if not approval_needed:
return issue_props['owner_email'], set(issue_props['reviewers'])
@@ -977,11 +969,11 @@ def _GerritOwnerAndReviewers(input_api, email_regexp, approval_needed=False):
If approval_needed is True, only reviewers who have approved the change
will be returned.
- Returns None if can't fetch issue properties from codereview.
"""
issue = input_api.change.issue
if not issue:
- return None
+ return None, (set() if approval_needed else
+ _ReviewersFromChange(input_api.change))
owner_email = input_api.gerrit.GetChangeOwner(issue)
reviewers = set(
« 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