From 2d8a2074c5dea835390bb6679b89cd0e0832a1e0 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Mon, 10 Apr 2017 15:02:18 +0200 Subject: [PATCH] Gerrit git cl upload: if -m is given, don't prompt for patchset title. R=sergiyb@chromium.org BUG=697625 Change-Id: I493bcc9212baf9030270cb71cf75ac969a67f2a0 Reviewed-on: https://chromium-review.googlesource.com/472724 Commit-Queue: Andrii Shyshkalov Reviewed-by: Sergiy Byelozyorov --- git_cl.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/git_cl.py b/git_cl.py index 723e56bd7..8ad75be07 100755 --- a/git_cl.py +++ b/git_cl.py @@ -2827,7 +2827,14 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): 'failed to fetch description from current Gerrit change %d\n' '%s' % (self.GetIssue(), self.GetIssueURL())) if not title: - default_title = RunGit(['show', '-s', '--format=%s', 'HEAD']).strip() + if options.message: + # For compatibility with Rietveld, if -m|--message is given on + # command line, title should be the first line of that message, + # which shouldn't be confused with CL description. + default_title = options.message.strip().split()[0] + else: + default_title = RunGit( + ['show', '-s', '--format=%s', 'HEAD']).strip() if options.force: title = default_title else: @@ -2940,6 +2947,10 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): print('Adding self-LGTM (Code-Review +1) because of TBRs') refspec_opts.append('l=Code-Review+1') + + # TODO(tandrii): options.message should be posted as a comment + # if --send-email is set on non-initial upload as Rietveld used to do it. + if title: if not re.match(r'^[\w ]+$', title): title = re.sub(r'[^\w ]', '', title)