From 91d2a5db01e886afa0ffdbe1b73ad6ac6aa3ee95 Mon Sep 17 00:00:00 2001 From: Xinan Lin Date: Fri, 4 Feb 2022 21:18:32 +0000 Subject: [PATCH] Allow to pass CC list when create a gerrit change CC list needs to be contained in notify_details. We can not use --param, because it is a map of recipient type to NotifyInfo entity. '--param' can not accept a dict from command line. BUG=NA TEST=gpaste/4774055988166656 Change-Id: I1560fe3a6136ab431052bc3fee7d4c8d989c8579 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3438508 Reviewed-by: Josip Sokcevic Commit-Queue: Xinan Lin --- gerrit_client.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gerrit_client.py b/gerrit_client.py index f3eb379da..2afb6bc21 100755 --- a/gerrit_client.py +++ b/gerrit_client.py @@ -236,16 +236,26 @@ def CMDcreatechange(parser, args): action='append', help='repeatable field value parameter, format: -p key=value') + parser.add_option('--cc', + dest='cc_list', + action='append', + help='CC address to notify, format: --cc foo@example.com') + (opt, args) = parser.parse_args(args) for p in opt.params: assert '=' in p, '--param is key=value, not "%s"' % p + params = list(tuple(p.split('=', 1)) for p in opt.params) + + if opt.cc_list: + params.append(('notify_details', {'CC': {'accounts': opt.cc_list}})) + result = gerrit_util.CreateChange( urlparse.urlparse(opt.host).netloc, opt.project, branch=opt.branch, subject=opt.subject, - params=list(tuple(p.split('=', 1)) for p in opt.params), + params=params, ) logging.info(result) write_result(result, opt)