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 <tandrii@chromium.org>
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 723e56b..8ad75be 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2827,7 +2827,14 @@
'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 @@
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)