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
diff --git a/doc/source/user/jobs.rst b/doc/source/user/jobs.rst
index b6a8564..5c90565 100644
--- a/doc/source/user/jobs.rst
+++ b/doc/source/user/jobs.rst
@@ -278,14 +278,12 @@
**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 @@
**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
+++++++++++++++++
diff --git a/zuul/executor/client.py b/zuul/executor/client.py
index cf70520..85ae68c 100644
--- a/zuul/executor/client.py
+++ b/zuul/executor/client.py
@@ -173,9 +173,11 @@
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: