Add strip_branch_ref compat option
This adds a compatability option to deal with a Gerrit behavior change between 2.11 and 2.13. Change-Id: I012485065e0fd8692e4f2ef787dd0a62be303314
This commit is contained in:
parent
c5a0259301
commit
b41c8cfa74
|
@ -42,6 +42,13 @@ Create a connection with gerrit.
|
|||
Optional: Keepalive timeout, 0 means no keepalive.
|
||||
``keepalive=60``
|
||||
|
||||
**strip_branch_ref**
|
||||
Optional: Earlier versions of Gerrit reported branch refs in the
|
||||
form "master" and later forms as "refs/heads/master". Set this to 1
|
||||
to enable compatibility with the earlier form by stripping the
|
||||
"refs/heads/" portion of the ref.
|
||||
``strip_branch_ref=1``
|
||||
|
||||
Gerrit Configuration
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ class GerritEventConnector(threading.Thread):
|
|||
if refupdate:
|
||||
event.project_name = refupdate.get('project')
|
||||
event.ref = refupdate.get('refName')
|
||||
if (self.connection.strip_branch_ref and
|
||||
event.ref.startswith('refs/heads/')):
|
||||
event.ref = event.ref[len('refs/heads/'):]
|
||||
event.oldrev = refupdate.get('oldRev')
|
||||
event.newrev = refupdate.get('newRev')
|
||||
# Map the event types to a field name holding a Gerrit
|
||||
|
@ -231,6 +234,8 @@ class GerritConnection(BaseConnection):
|
|||
self.port = int(self.connection_config.get('port', 29418))
|
||||
self.keyfile = self.connection_config.get('sshkey', None)
|
||||
self.keepalive = int(self.connection_config.get('keepalive', 60))
|
||||
self.strip_branch_ref = bool(self.connection_config.get(
|
||||
'strip_branch_ref'))
|
||||
self.watcher_thread = None
|
||||
self.event_queue = None
|
||||
self.client = None
|
||||
|
|
Loading…
Reference in New Issue