Commit 8b478f04 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

PRESUBMIT: Be resilient to changes with no Code-Review label

Bug: 750694
Change-Id: I69778c3ea0789795ad7e50d11bf677df8f7bc262
Reviewed-on: https://chromium-review.googlesource.com/594839Reviewed-by: 's avatarDaniel Jacques <dnj@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
parent 8038dfe3
......@@ -247,10 +247,19 @@ class GerritAccessor(object):
return self.GetChangeInfo(issue)['owner']['email']
def GetChangeReviewers(self, issue, approving_only=True):
cr = self.GetChangeInfo(issue)['labels']['Code-Review']
max_value = max(int(k) for k in cr['values'].keys())
return [r.get('email') for r in cr.get('all', [])
if not approving_only or r.get('value', 0) == max_value]
changeinfo = self.GetChangeInfo(issue)
if approving_only:
labelinfo = changeinfo.get('labels', {}).get('Code-Review', {})
values = labelinfo.get('values', {}).keys()
try:
max_value = max(int(v) for v in values)
reviewers = [r for r in labelinfo.get('all', [])
if r.get('value', 0) == max_value]
except ValueError: # values is the empty list
reviewers = []
else:
reviewers = changeinfo.get('reviewers', {}).get('REVIEWER', [])
return [r.get('email') for r in reviewers]
class OutputApi(object):
......
......@@ -2387,6 +2387,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
u'-1': u"I would prefer that you didn't submit this",
u'-2': u'Do not submit'}
}},
"reviewers": {"REVIEWER": [{u'email': u'ben@example.com'}]},
}
self.AssertOwnersWorks(approvers=set(['ben@example.com']),
gerrit_response=response,
......@@ -2414,6 +2415,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
u'+1': u'Looks good to me',
u'-1': u"I would prefer that you didn't submit this"}
}},
"reviewers": {"REVIEWER": [{u'email': u'ben@example.com'}]},
}
self.AssertOwnersWorks(approvers=set(['ben@example.com']),
gerrit_response=response,
......@@ -2462,6 +2464,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
u'-1': u"I would prefer that you didn't submit this",
u'-2': u'Do not submit'}
}},
"reviewers": {"REVIEWER": [{u'email': u'ben@example.com'}]},
}
self.AssertOwnersWorks(
approvers=set(),
......@@ -2494,6 +2497,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
u'+1': u'Looks good to me',
u'-1': u"I would prefer that you didn't submit this"}
}},
"reviewers": {"REVIEWER": [{u'email': u'ben@example.com'}]},
}
self.AssertOwnersWorks(
approvers=set(),
......
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