Added topic flag to git cl split functionality.

Change-Id: Ie3314cfe45e008f1df8b21ff16abda0980a5225e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4653533
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Rachael Newitt <renewitt@google.com>
changes/33/4653533/3
Rachael Newitt 2 years ago committed by LUCI CQ
parent b56b654322
commit 03e4912518

@ -5136,6 +5136,9 @@ def CMDsplit(parser, args):
'--max-depth=1 will only split by top-level ' '--max-depth=1 will only split by top-level '
'directory. Specifying a value less than 1 means no ' 'directory. Specifying a value less than 1 means no '
'limit on max depth.') 'limit on max depth.')
parser.add_option('--topic',
default=None,
help='Topic to specify when uploading')
options, _ = parser.parse_args(args) options, _ = parser.parse_args(args)
if not options.description_file: if not options.description_file:
@ -5147,7 +5150,7 @@ def CMDsplit(parser, args):
return split_cl.SplitCl(options.description_file, options.comment_file, return split_cl.SplitCl(options.description_file, options.comment_file,
Changelist, WrappedCMDupload, options.dry_run, Changelist, WrappedCMDupload, options.dry_run,
options.cq_dry_run, options.enable_auto_submit, options.cq_dry_run, options.enable_auto_submit,
options.max_depth, settings.GetRoot()) options.max_depth, options.topic, settings.GetRoot())
@subcommand.usage('DEPRECATED') @subcommand.usage('DEPRECATED')

@ -70,7 +70,7 @@ def AddUploadedByGitClSplitToDescription(description):
def UploadCl(refactor_branch, refactor_branch_upstream, directory, files, def UploadCl(refactor_branch, refactor_branch_upstream, directory, files,
description, comment, reviewers, changelist, cmd_upload, description, comment, reviewers, changelist, cmd_upload,
cq_dry_run, enable_auto_submit, repository_root): cq_dry_run, enable_auto_submit, topic, repository_root):
"""Uploads a CL with all changes to |files| in |refactor_branch|. """Uploads a CL with all changes to |files| in |refactor_branch|.
Args: Args:
@ -86,6 +86,7 @@ def UploadCl(refactor_branch, refactor_branch_upstream, directory, files,
cmd_upload: The function associated with the git cl upload command. cmd_upload: The function associated with the git cl upload command.
cq_dry_run: If CL uploads should also do a cq dry run. cq_dry_run: If CL uploads should also do a cq dry run.
enable_auto_submit: If CL uploads should also enable auto submit. enable_auto_submit: If CL uploads should also enable auto submit.
topic: Topic to associate with uploaded CLs.
""" """
# Create a branch. # Create a branch.
if not CreateBranchForDirectory( if not CreateBranchForDirectory(
@ -126,6 +127,8 @@ def UploadCl(refactor_branch, refactor_branch_upstream, directory, files,
upload_args.append('--send-mail') upload_args.append('--send-mail')
if enable_auto_submit: if enable_auto_submit:
upload_args.append('--enable-auto-submit') upload_args.append('--enable-auto-submit')
if topic:
upload_args.append('--topic={}'.format(topic))
print('Uploading CL for ' + directory + '...') print('Uploading CL for ' + directory + '...')
ret = cmd_upload(upload_args) ret = cmd_upload(upload_args)
@ -165,7 +168,7 @@ def GetFilesSplitByOwners(files, max_depth):
def PrintClInfo(cl_index, num_cls, directory, file_paths, description, def PrintClInfo(cl_index, num_cls, directory, file_paths, description,
reviewers): reviewers, topic):
"""Prints info about a CL. """Prints info about a CL.
Args: Args:
@ -176,6 +179,7 @@ def PrintClInfo(cl_index, num_cls, directory, file_paths, description,
file_paths: A list of files in this CL. file_paths: A list of files in this CL.
description: The CL description. description: The CL description.
reviewers: A set of reviewers for this CL. reviewers: A set of reviewers for this CL.
topic: Topic to set for this CL.
""" """
description_lines = FormatDescriptionOrComment(description, description_lines = FormatDescriptionOrComment(description,
directory).splitlines() directory).splitlines()
@ -184,13 +188,14 @@ def PrintClInfo(cl_index, num_cls, directory, file_paths, description,
print('CL {}/{}'.format(cl_index, num_cls)) print('CL {}/{}'.format(cl_index, num_cls))
print('Path: {}'.format(directory)) print('Path: {}'.format(directory))
print('Reviewers: {}'.format(', '.join(reviewers))) print('Reviewers: {}'.format(', '.join(reviewers)))
print('Topic: {}'.format(topic))
print('\n' + indented_description + '\n') print('\n' + indented_description + '\n')
print('\n'.join(file_paths)) print('\n'.join(file_paths))
print() print()
def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run, def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run,
cq_dry_run, enable_auto_submit, max_depth, repository_root): cq_dry_run, enable_auto_submit, max_depth, topic, repository_root):
""""Splits a branch into smaller branches and uploads CLs. """"Splits a branch into smaller branches and uploads CLs.
Args: Args:
@ -203,6 +208,7 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run,
enable_auto_submit: If CL uploads should also enable auto submit. enable_auto_submit: If CL uploads should also enable auto submit.
max_depth: The maximum directory depth to search for OWNERS files. A value max_depth: The maximum directory depth to search for OWNERS files. A value
less than 1 means no limit. less than 1 means no limit.
topic: Topic to associate with split CLs.
Returns: Returns:
0 in case of success. 1 in case of error. 0 in case of success. 1 in case of error.
@ -270,11 +276,11 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run,
file_paths, exclude=[author, cl.owners_client.EVERYONE]) file_paths, exclude=[author, cl.owners_client.EVERYONE])
if dry_run: if dry_run:
PrintClInfo(cl_index, num_cls, directory, file_paths, description, PrintClInfo(cl_index, num_cls, directory, file_paths, description,
reviewers) reviewers, topic)
else: else:
UploadCl(refactor_branch, refactor_branch_upstream, directory, files, UploadCl(refactor_branch, refactor_branch_upstream, directory, files,
description, comment, reviewers, changelist, cmd_upload, description, comment, reviewers, changelist, cmd_upload,
cq_dry_run, enable_auto_submit, repository_root) cq_dry_run, enable_auto_submit, topic, repository_root)
# Go back to the original branch. # Go back to the original branch.
git.run('checkout', refactor_branch) git.run('checkout', refactor_branch)

Loading…
Cancel
Save