Case sensitive label matching
After upgrading Gerrit to 2.13 our gate stopped working. The reason for this is that after a successful gate run zuul does something like 'gerrit review --label verified=2 --submit'. The verified label in Gerrit by default is configured as 'Verified'. The newer version of gerrit behaves different now. It accepts the +2 vote on verified but doesn't submit the patch anymore if the casing is not correct. This forces us to specify the label in the same casing as gerrit expects. In that case the tolower() in canMerge prevents the patch from entering the gate. In order to avoid confusion and be consistent, avoid any case conversions and use the labels exactly as defined in Gerrit. Note that this patch requires changes to the pipelines such that the labels are spelled exactly as defined in Gerrit. Change-Id: I9713a075e07b268e4f2620c0862c128158283c7c
This commit is contained in:
committed by
Tobias Henkel
parent
961bb1a876
commit
ea98a194cc
@@ -581,7 +581,7 @@ class GerritConnection(BaseConnection):
|
||||
continue
|
||||
elif label['status'] in ['NEED', 'REJECT']:
|
||||
# It may be our own rejection, so we ignore
|
||||
if label['label'].lower() not in allow_needs:
|
||||
if label['label'] not in allow_needs:
|
||||
return False
|
||||
continue
|
||||
else:
|
||||
|
||||
@@ -24,11 +24,6 @@ from zuul.driver.util import time_to_seconds
|
||||
EMPTY_GIT_REF = '0' * 40 # git sha of all zeros, used during creates/deletes
|
||||
|
||||
|
||||
def normalize_category(name):
|
||||
name = name.lower()
|
||||
return re.sub(' ', '-', name)
|
||||
|
||||
|
||||
class GerritChange(Change):
|
||||
def __init__(self, project):
|
||||
super(GerritChange, self).__init__(project)
|
||||
@@ -109,7 +104,7 @@ class GerritApprovalFilter(object):
|
||||
else:
|
||||
if not isinstance(v, list):
|
||||
v = [v]
|
||||
if (normalize_category(approval['description']) != k or
|
||||
if (approval['description'] != k or
|
||||
int(approval['value']) not in v):
|
||||
return False
|
||||
return True
|
||||
@@ -281,8 +276,8 @@ class GerritEventFilter(EventFilter, GerritApprovalFilter):
|
||||
for category, value in self.event_approvals.items():
|
||||
matches_approval = False
|
||||
for eapp in event.approvals:
|
||||
if (normalize_category(eapp['description']) == category and
|
||||
int(eapp['value']) == int(value)):
|
||||
if (eapp['description'] == category and
|
||||
int(eapp['value']) == int(value)):
|
||||
matches_approval = True
|
||||
if not matches_approval:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user