From 566e9d0177a5f98dbc435f99aa185b27bf70f2f4 Mon Sep 17 00:00:00 2001 From: manukh Date: Thu, 30 Jun 2022 19:49:53 +0000 Subject: [PATCH] [git-cl] If set, use `options.title` for initial uploads. Change-Id: Ia57b7a7b769d352e05820af0e40a52fcab471ddb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3736424 Reviewed-by: Gavin Mak Commit-Queue: manuk hovanesian --- git_cl.py | 7 +++---- tests/git_cl_test.py | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/git_cl.py b/git_cl.py index 35767c19d..9be92158e 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1504,8 +1504,9 @@ class Changelist(object): return change_description def _GetTitleForUpload(self, options): - # When not squashing, just return options.title. - if not options.squash: + # When not squashing or options.title is provided, just return + # options.title. + if not options.squash or options.title: return options.title # On first upload, patchset title is always this string, while options.title @@ -1515,8 +1516,6 @@ class Changelist(object): # When uploading subsequent patchsets, options.message is taken as the title # if options.title is not provided. - if options.title: - return options.title if options.message: return options.message.strip() diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index e08a8507d..0c72c274c 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -878,11 +878,11 @@ class TestGitCl(unittest.TestCase): metrics_arguments.append('notify=NONE') # If issue is given, then description is fetched from Gerrit instead. - if issue is None: - if squash: - title = 'Initial upload' - else: - if not title: + if not title: + if issue is None: + if squash: + title = 'Initial upload' + else: calls += [ ((['git', 'show', '-s', '--format=%s', 'HEAD'],), ''), (('ask_for_data', 'Title for patchset []: '), 'User input'), @@ -1378,6 +1378,7 @@ class TestGitCl(unittest.TestCase): ['-f', '-t', 'title'], 'title\n\ndesc\n\nChange-Id: 123456789', [], + title='title', force=True, squash=True, log_description='desc',