From cf45d48979de09d113d441a9cd10a60c3a81b3ff Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 9 Nov 2017 15:04:58 +1100 Subject: [PATCH] Make enqueue-ref 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 --- zuul/cmd/client.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py index a11f2f0231..7a26a62ff2 100755 --- a/zuul/cmd/client.py +++ b/zuul/cmd/client.py @@ -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"""