Commit 830dc0bc authored by tandrii@chromium.org's avatar tandrii@chromium.org

Properly expose already used elsewhere functionality.

Also make _RietveldOwnerAndReviewers have same semantics as before,
to resolve immediate bug until chromium checkouts of developers are
updated.

BUG=609832
R=machenbach@chromium.org

Review-Url: https://codereview.chromium.org/1955223002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@300494 0039d316-1c4b-4281-b951-d872f2087c98
parent 78d65556
...@@ -875,7 +875,7 @@ def CheckOwners(input_api, output_api, source_file_filter=None): ...@@ -875,7 +875,7 @@ def CheckOwners(input_api, output_api, source_file_filter=None):
input_api.change.AffectedFiles(file_filter=source_file_filter)]) input_api.change.AffectedFiles(file_filter=source_file_filter)])
owners_db = input_api.owners_db owners_db = input_api.owners_db
owner_email, reviewers = _CodereviewOwnersAndReviewers( owner_email, reviewers = GetCodereviewOwnerAndReviewers(
input_api, input_api,
owners_db.email_regexp, owners_db.email_regexp,
approval_needed=input_api.is_committing) approval_needed=input_api.is_committing)
...@@ -904,25 +904,17 @@ def CheckOwners(input_api, output_api, source_file_filter=None): ...@@ -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 [output('Missing LGTM from someone other than %s' % owner_email)]
return [] 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. """Return the owner and reviewers of a change, if any.
If approval_needed is True, only reviewers who have approved the change If approval_needed is True, only reviewers who have approved the change
will be returned. will be returned.
""" """
if input_api.change.issue: # Rietveld is default.
if input_api.gerrit: func = _RietveldOwnerAndReviewers
res = _GerritOwnerAndReviewers(input_api, email_regexp, approval_needed) if input_api.gerrit:
else: func = _GerritOwnerAndReviewers
# Rietveld is default. return func(input_api, email_regexp, approval_needed)
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
def _GetRietveldIssueProps(input_api, messages): def _GetRietveldIssueProps(input_api, messages):
...@@ -953,11 +945,11 @@ def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): ...@@ -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 If approval_needed is True, only reviewers who have approved the change
will be returned. will be returned.
Returns None if can't fetch issue properties from codereview.
""" """
issue_props = _GetRietveldIssueProps(input_api, True) issue_props = _GetRietveldIssueProps(input_api, True)
if not issue_props: if not issue_props:
return None return None, (set() if approval_needed else
_ReviewersFromChange(input_api.change))
if not approval_needed: if not approval_needed:
return issue_props['owner_email'], set(issue_props['reviewers']) return issue_props['owner_email'], set(issue_props['reviewers'])
...@@ -977,11 +969,11 @@ def _GerritOwnerAndReviewers(input_api, email_regexp, approval_needed=False): ...@@ -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 If approval_needed is True, only reviewers who have approved the change
will be returned. will be returned.
Returns None if can't fetch issue properties from codereview.
""" """
issue = input_api.change.issue issue = input_api.change.issue
if not issue: if not issue:
return None return None, (set() if approval_needed else
_ReviewersFromChange(input_api.change))
owner_email = input_api.gerrit.GetChangeOwner(issue) owner_email = input_api.gerrit.GetChangeOwner(issue)
reviewers = set( reviewers = set(
......
...@@ -1886,6 +1886,7 @@ class CannedChecksUnittest(PresubmitTestsBase): ...@@ -1886,6 +1886,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty',
'RunPythonUnitTests', 'RunPylint', 'RunPythonUnitTests', 'RunPylint',
'RunUnitTests', 'RunUnitTestsInDirectory', 'RunUnitTests', 'RunUnitTestsInDirectory',
'GetCodereviewOwnerAndReviewers',
'GetPythonUnitTests', 'GetPylint', 'GetPythonUnitTests', 'GetPylint',
'GetUnitTests', 'GetUnitTestsInDirectory', 'GetUnitTestsRecursively', 'GetUnitTests', 'GetUnitTestsInDirectory', 'GetUnitTestsRecursively',
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment