Commit 91d2a5db authored by Xinan Lin's avatar Xinan Lin Committed by LUCI CQ

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/+/3438508Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
parent 26b592af
...@@ -236,16 +236,26 @@ def CMDcreatechange(parser, args): ...@@ -236,16 +236,26 @@ def CMDcreatechange(parser, args):
action='append', action='append',
help='repeatable field value parameter, format: -p key=value') 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) (opt, args) = parser.parse_args(args)
for p in opt.params: for p in opt.params:
assert '=' in p, '--param is key=value, not "%s"' % p 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( result = gerrit_util.CreateChange(
urlparse.urlparse(opt.host).netloc, urlparse.urlparse(opt.host).netloc,
opt.project, opt.project,
branch=opt.branch, branch=opt.branch,
subject=opt.subject, subject=opt.subject,
params=list(tuple(p.split('=', 1)) for p in opt.params), params=params,
) )
logging.info(result) logging.info(result)
write_result(result, opt) write_result(result, opt)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment