For determining OWNERS, drop reviewers specified via '-r' that aren't in email address format.

BUG=none
R=agable@chromium.org

Review URL: https://codereview.chromium.org/215153004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@262641 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
isherman@chromium.org 11 years ago
parent 3676b3f270
commit 103ae03aa1

@ -859,7 +859,9 @@ def _ReviewersFromChange(change):
reviewers.update(set([r.strip() for r in change.R.split(',')])) reviewers.update(set([r.strip() for r in change.R.split(',')]))
if change.TBR: if change.TBR:
reviewers.update(set([r.strip() for r in change.TBR.split(',')])) reviewers.update(set([r.strip() for r in change.TBR.split(',')]))
return reviewers
# Drop reviewers that aren't specified in email address format.
return set(reviewer for reviewer in reviewers if '@' in reviewer)
def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False):

@ -2572,7 +2572,8 @@ class CannedChecksUnittest(PresubmitTestsBase):
def AssertOwnersWorks(self, tbr=False, issue='1', approvers=None, def AssertOwnersWorks(self, tbr=False, issue='1', approvers=None,
reviewers=None, is_committing=True, rietveld_response=None, reviewers=None, is_committing=True, rietveld_response=None,
uncovered_files=None, expected_output='', author_counts_as_owner=True): uncovered_files=None, expected_output='', author_counts_as_owner=True,
manually_specified_reviewers=None):
if approvers is None: if approvers is None:
# The set of people who lgtm'ed a change. # The set of people who lgtm'ed a change.
approvers = set() approvers = set()
@ -2583,11 +2584,13 @@ class CannedChecksUnittest(PresubmitTestsBase):
reviewers = approvers reviewers = approvers
if uncovered_files is None: if uncovered_files is None:
uncovered_files = set() uncovered_files = set()
if manually_specified_reviewers is None:
manually_specified_reviewers = []
change = self.mox.CreateMock(presubmit.Change) change = self.mox.CreateMock(presubmit.Change)
change.issue = issue change.issue = issue
change.author_email = 'john@example.com' change.author_email = 'john@example.com'
change.R = '' change.R = ','.join(manually_specified_reviewers)
change.TBR = '' change.TBR = ''
affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile) affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile)
input_api = self.MockInputApi(change, False) input_api = self.MockInputApi(change, False)
@ -2614,7 +2617,6 @@ class CannedChecksUnittest(PresubmitTestsBase):
people = approvers people = approvers
else: else:
people = reviewers people = reviewers
change.R = ','.join(reviewers)
if issue: if issue:
input_api.rietveld.get_issue_properties( input_api.rietveld.get_issue_properties(
@ -2729,13 +2731,28 @@ class CannedChecksUnittest(PresubmitTestsBase):
def testCannedCheckOwners_NoIssueLocalReviewers(self): def testCannedCheckOwners_NoIssueLocalReviewers(self):
self.AssertOwnersWorks(issue=None, self.AssertOwnersWorks(issue=None,
reviewers=set(['jane@example.com']), reviewers=set(['jane@example.com']),
manually_specified_reviewers=['jane@example.com'],
expected_output="OWNERS check failed: this change has no Rietveld " expected_output="OWNERS check failed: this change has no Rietveld "
"issue number, so we can't check it for approvals.\n") "issue number, so we can't check it for approvals.\n")
self.AssertOwnersWorks(issue=None, self.AssertOwnersWorks(issue=None,
reviewers=set(['jane@example.com']), reviewers=set(['jane@example.com']),
manually_specified_reviewers=['jane@example.com'],
is_committing=False, is_committing=False,
expected_output='') expected_output='')
def testCannedCheckOwners_NoIssueLocalReviewersDontInferEmailDomain(self):
self.AssertOwnersWorks(issue=None,
reviewers=set(['jane']),
manually_specified_reviewers=['jane@example.com'],
expected_output="OWNERS check failed: this change has no Rietveld "
"issue number, so we can't check it for approvals.\n")
self.AssertOwnersWorks(issue=None,
uncovered_files=set(['foo']),
manually_specified_reviewers=['jane'],
is_committing=False,
expected_output='Missing OWNER reviewers for these files:\n'
' foo\n')
def testCannedCheckOwners_NoLGTM(self): def testCannedCheckOwners_NoLGTM(self):
self.AssertOwnersWorks(expected_output='Missing LGTM from someone ' self.AssertOwnersWorks(expected_output='Missing LGTM from someone '
'other than john@example.com\n') 'other than john@example.com\n')

Loading…
Cancel
Save