gerrit_client: validate --param options

Passing an invalid --param option in leads to a crash lower down in
the gerrit modules which can be hard to trace back to the original
error: the user forgot the "key" in the "key=value".

Change-Id: I6fe5fab0fad15cf8d25173e0f1c8ea130efc44ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2558651
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
changes/51/2558651/2
Mike Frysinger 5 years ago committed by LUCI CQ
parent 295dd1879f
commit 8820ab859b

@ -46,6 +46,8 @@ def CMDmovechanges(parser, args):
(opt, args) = parser.parse_args(args)
assert opt.destination_branch, "--destination_branch not defined"
for p in opt.params:
assert '=' in p, '--param is key=value, not "%s"' % p
host = urlparse.urlparse(opt.host).netloc
limit = 100
@ -108,6 +110,8 @@ def CMDchanges(parser, args):
'(starting with the most recent)')
(opt, args) = parser.parse_args(args)
for p in opt.params:
assert '=' in p, '--param is key=value, not "%s"' % p
result = gerrit_util.QueryChanges(
urlparse.urlparse(opt.host).netloc,

Loading…
Cancel
Save