From 271a40782520bbbacafc3e9d852d18d6b6b36eda Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 21 Jul 2017 13:56:18 -0700 Subject: [PATCH] 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 --- doc/source/user/jobs.rst | 12 ++++-------- zuul/executor/client.py | 6 ++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/source/user/jobs.rst b/doc/source/user/jobs.rst index b6a85649a7..5c905659c7 100644 --- a/doc/source/user/jobs.rst +++ b/doc/source/user/jobs.rst @@ -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 +++++++++++++++++ diff --git a/zuul/executor/client.py b/zuul/executor/client.py index cf70520988..85ae68c034 100644 --- a/zuul/executor/client.py +++ b/zuul/executor/client.py @@ -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: