Use undefined values instead of 40 zeroes

The git shas 40*'0' are used on the wire protocol to indicate that
the receiving end should create or delete the ref regardless of
its current value.  Both Gerrit and GitHub pass these through
on their event streams unaltered.

To make this more convenient for ansible users, translate these
values into undefined variables.  So that rather than deterimining
that a ref was created by comparing oldrev to
0000000000000000000000000000000000000000 the user can say
"oldrev is not defined".

Change-Id: I1a2a30a0ad53d50325f189a3829f7428db72e1d1
This commit is contained in:
James E. Blair 2017-07-21 13:56:18 -07:00
parent 6665c1a358
commit 271a407825
2 changed files with 8 additions and 10 deletions

View File

@ -278,14 +278,12 @@ available:
**zuul.oldrev**
If the item was enqueued as the result of a tag being deleted, the
previous git sha of the tag will be included here. If the tag was
created, this will be set to the value
0000000000000000000000000000000000000000.
created, this variable will be undefined.
**zuul.newrev**
If the item was enqueued as the result of a tag being created, the
new git sha of the tag will be included here. If the tag was
deleted, this will be set to the value
0000000000000000000000000000000000000000.
deleted, this variable will be undefined.
Ref Items
+++++++++
@ -298,14 +296,12 @@ available:
**zuul.oldrev**
If the item was enqueued as the result of a ref being deleted, the
previous git sha of the ref will be included here. If the ref was
created, this will be set to the value
0000000000000000000000000000000000000000.
created, this variable will be undefined.
**zuul.newrev**
If the item was enqueued as the result of a ref being created, the
new git sha of the ref will be included here. If the ref was
deleted, this will be set to the value
0000000000000000000000000000000000000000.
deleted, this variable will be undefined.
Working Directory
+++++++++++++++++

View File

@ -173,9 +173,11 @@ class ExecutorClient(object):
zuul_params['change'] = str(item.change.number)
if hasattr(item.change, 'patchset'):
zuul_params['patchset'] = str(item.change.patchset)
if hasattr(item.change, 'oldrev') and item.change.oldrev:
if (hasattr(item.change, 'oldrev') and item.change.oldrev
and item.change.oldrev != '0' * 40):
zuul_params['oldrev'] = item.change.oldrev
if hasattr(item.change, 'newrev') and item.change.newrev:
if (hasattr(item.change, 'newrev') and item.change.newrev
and item.change.newrev != '0' * 40):
zuul_params['newrev'] = item.change.newrev
zuul_params['items'] = []
for i in all_items: