Merge "check-release-approval: handle no-review case"
This commit is contained in:
commit
7b440dac3a
|
@ -61,20 +61,14 @@ class GerritChange(object):
|
||||||
with open(os.path.join(args.governance, PROJECTS_YAML), 'r') as dfile:
|
with open(os.path.join(args.governance, PROJECTS_YAML), 'r') as dfile:
|
||||||
self.gov_data = yaml.safe_load(dfile)
|
self.gov_data = yaml.safe_load(dfile)
|
||||||
|
|
||||||
try:
|
self.load_from_gerrit(args.changeid)
|
||||||
self.load_from_gerrit(args.changeid)
|
|
||||||
except KeyError:
|
|
||||||
LOG.warning(
|
|
||||||
'\ndata from gerrit is missing required keys:\n\n%s\n',
|
|
||||||
json.dumps(self.raw_data, indent=2))
|
|
||||||
raise
|
|
||||||
|
|
||||||
self.workspace = args.releases
|
self.workspace = args.releases
|
||||||
|
|
||||||
def load_from_gerrit(self, changeid):
|
def load_from_gerrit(self, changeid):
|
||||||
# Grab changeid details from Gerrit
|
# Grab changeid details from Gerrit
|
||||||
call = 'changes/%s/detail' % changeid + \
|
call = 'changes/%s' % changeid + \
|
||||||
'?o=CURRENT_REVISION&o=CURRENT_FILES'
|
'?o=CURRENT_REVISION&o=CURRENT_FILES&o=DETAILED_LABELS' + \
|
||||||
|
'&o=DETAILED_ACCOUNTS'
|
||||||
raw = requests.get(GERRIT_URL + call)
|
raw = requests.get(GERRIT_URL + call)
|
||||||
|
|
||||||
# Gerrit's REST API prepends a JSON-breaker to avoid XSS
|
# Gerrit's REST API prepends a JSON-breaker to avoid XSS
|
||||||
|
@ -93,12 +87,18 @@ class GerritChange(object):
|
||||||
raw, raw.url, trimmed)
|
raw, raw.url, trimmed)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Instantiate object with retrieved data
|
# Extract approvers from JSON data. Approvers include change owner
|
||||||
self.raw_data = decoded
|
# and anyone who voted Code-Review+1. NB: Gerrit does not fill
|
||||||
self.approvers = [i['email']
|
# labels.CodeReview.all unless there is a vote already
|
||||||
for i in decoded['labels']['Code-Review']['all']
|
self.approvers = [decoded['owner']['email']]
|
||||||
if i['value'] > 0]
|
if 'all' in decoded['labels']['Code-Review']:
|
||||||
self.approvers.append(decoded['owner']['email'])
|
self.approvers.extend([
|
||||||
|
i['email']
|
||||||
|
for i in decoded['labels']['Code-Review']['all']
|
||||||
|
if i['value'] > 0
|
||||||
|
])
|
||||||
|
|
||||||
|
# Extract list of modified deliverables files from JSON data
|
||||||
currev = decoded['current_revision']
|
currev = decoded['current_revision']
|
||||||
self.deliv_files = [
|
self.deliv_files = [
|
||||||
x for x in decoded['revisions'][currev]['files'].keys()
|
x for x in decoded['revisions'][currev]['files'].keys()
|
||||||
|
|
Loading…
Reference in New Issue