Make enqueue-ref <new|old>rev optional

As described in the documentation in
Ibd7ee306bc461d1597c9c8febcaad89a48b9ff96 the new/old rev arguments
aren't required in all situations.  For example when triggering a
periodic job and pretending to be the timer event, you just need the
refs/head/branch.  For a release/tag replay, I believe you only need
the newref, so setting them both to zero by default triggers the check
incorrectly.

Thus we set the arguments to None intially and only if they are
explicitly set do we check they're not the same.  If they're unset by
the user, we just set them to zero for the rpc calls.

Change-Id: I8125010efcf8d26dc3a99c87fe2c945314072b72
This commit is contained in:
Ian Wienand 2017-11-09 15:04:58 +11:00
parent 25f3a31ec0
commit cf45d48979
1 changed files with 13 additions and 6 deletions

View File

@ -99,11 +99,9 @@ class Client(zuul.cmd.ZuulApp):
cmd_enqueue.add_argument('--ref', help='ref name',
required=True)
cmd_enqueue.add_argument(
'--oldrev', help='old revision',
default='0000000000000000000000000000000000000000')
'--oldrev', help='old revision', default=None)
cmd_enqueue.add_argument(
'--newrev', help='new revision',
default='0000000000000000000000000000000000000000')
'--newrev', help='new revision', default=None)
cmd_enqueue.set_defaults(func=self.enqueue_ref)
cmd_promote = subparsers.add_parser('promote',
@ -140,8 +138,17 @@ class Client(zuul.cmd.ZuulApp):
parser.print_help()
sys.exit(1)
if self.args.func == self.enqueue_ref:
if self.args.oldrev == self.args.newrev:
parser.error("The old and new revisions must not be the same.")
# if oldrev or newrev is set, ensure they're not the same
if (self.args.oldrev is not None) or \
(self.args.newrev is not None):
if self.args.oldrev == self.args.newrev:
parser.error(
"The old and new revisions must not be the same.")
# if they're not set, we pad them out to zero
if self.args.oldrev is None:
self.args.oldrev = '0000000000000000000000000000000000000000'
if self.args.newrev is None:
self.args.newrev = '0000000000000000000000000000000000000000'
def setup_logging(self):
"""Client logging does not rely on conf file"""