Properly support WIP in Gerrit 2.8

Since WIP is just a workflow vote now, the old method of filtering
out those patches is no longer working.  This change should take
care of that.

Change-Id: I8a028de992399df324927a4b0c191e7a5b684773
This commit is contained in:
Ben Nemec 2014-05-21 14:40:23 +00:00
parent b1c0cdf956
commit f6a80e3be4
2 changed files with 26 additions and 1 deletions

View File

@ -298,7 +298,7 @@ def main(argv=None):
continue continue
if not options.stable and 'stable' in change['branch']: if not options.stable and 'stable' in change['branch']:
continue continue
if change['status'] != 'NEW': if utils.is_workinprogress(change):
# Filter out WORKINPROGRESS # Filter out WORKINPROGRESS
continue continue
latest_patch = change['patchSets'][-1] latest_patch = change['patchSets'][-1]

View File

@ -203,6 +203,31 @@ def patch_set_approved(patch_set):
return False return False
def is_workinprogress(change):
"""Return True if the patchset is WIP
:param dict change: De-serialized dict of a gerrit change
:return: True if one of the votes on the review sets it to WIP.
"""
# This indicates WIP for older Gerrit versions
if change['status'] != 'NEW':
return True
# Gerrit 2.8 WIP
last_patch = change['patchSets'][-1]
try:
approvals = last_patch['approvals']
except KeyError:
# Means no one has voted on the latest patch set yet
return False
for a in approvals:
if a['type'] == 'Workflow' and int(a['value']) < 0:
return True
return False
def get_age_of_patch(patch, now_ts): def get_age_of_patch(patch, now_ts):
"""Compute the number of seconds since the patch submission and now. """Compute the number of seconds since the patch submission and now.