Only prompt for clean titles if manually set

We have to clean up the title, but if the user hasn't expressed any
input about the title (i.e. it's one we autogenerated), then don't
bother them by pointing it out.

BUG=684079

Change-Id: I8215e0a30f786466697fe1df178ca90e1980d9b0
Reviewed-on: https://chromium-review.googlesource.com/431162
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrew Bonventre <andybons@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
changes/62/431162/2
Aaron Gable 9 years ago committed by Commit Bot
parent 5b04a57ab2
commit 856585ddec

@ -2653,6 +2653,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
# This may be None; default fallback value is determined in logic below.
title = options.title
automatic_title = False
if options.squash:
self._GerritCommitMsgHookCheck(offer_removal=not options.force)
@ -2667,6 +2668,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
default_title = RunGit(['show', '-s', '--format=%s', 'HEAD']).strip()
title = ask_for_data(
'Title for patchset [%s]: ' % default_title) or default_title
if title == default_title:
automatic_title = True
change_id = self._GetChangeDetail()['change_id']
while True:
footer_change_ids = git_footers.get_footer_change_id(message)
@ -2715,6 +2718,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
# On first upload, patchset title is always this string, while
# --title flag gets converted to first line of message.
title = 'Initial upload'
automatic_title = True
if not change_desc.description:
DieWithError("Description is empty. Aborting...")
message = change_desc.description
@ -2795,10 +2799,11 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
if title:
if not re.match(r'^[\w ]+$', title):
title = re.sub(r'[^\w ]', '', title)
print('WARNING: Patchset title may only contain alphanumeric chars '
'and spaces. Cleaned up title:\n%s' % title)
if not options.force:
ask_for_data('Press enter to continue, Ctrl+C to abort')
if not automatic_title:
print('WARNING: Patchset title may only contain alphanumeric chars '
'and spaces. Cleaned up title:\n%s' % title)
if not options.force:
ask_for_data('Press enter to continue, Ctrl+C to abort')
# Per doc, spaces must be converted to underscores, and Gerrit will do the
# reverse on its side.
refspec_opts.append('m=' + title.replace(' ', '_'))

Loading…
Cancel
Save