Commit 856585dd authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

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: 's avatarAndrew Bonventre <andybons@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
parent 5b04a57a
...@@ -2653,6 +2653,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2653,6 +2653,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
# This may be None; default fallback value is determined in logic below. # This may be None; default fallback value is determined in logic below.
title = options.title title = options.title
automatic_title = False
if options.squash: if options.squash:
self._GerritCommitMsgHookCheck(offer_removal=not options.force) self._GerritCommitMsgHookCheck(offer_removal=not options.force)
...@@ -2667,6 +2668,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2667,6 +2668,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
default_title = RunGit(['show', '-s', '--format=%s', 'HEAD']).strip() default_title = RunGit(['show', '-s', '--format=%s', 'HEAD']).strip()
title = ask_for_data( title = ask_for_data(
'Title for patchset [%s]: ' % default_title) or default_title 'Title for patchset [%s]: ' % default_title) or default_title
if title == default_title:
automatic_title = True
change_id = self._GetChangeDetail()['change_id'] change_id = self._GetChangeDetail()['change_id']
while True: while True:
footer_change_ids = git_footers.get_footer_change_id(message) footer_change_ids = git_footers.get_footer_change_id(message)
...@@ -2715,6 +2718,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2715,6 +2718,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
# On first upload, patchset title is always this string, while # On first upload, patchset title is always this string, while
# --title flag gets converted to first line of message. # --title flag gets converted to first line of message.
title = 'Initial upload' title = 'Initial upload'
automatic_title = True
if not change_desc.description: if not change_desc.description:
DieWithError("Description is empty. Aborting...") DieWithError("Description is empty. Aborting...")
message = change_desc.description message = change_desc.description
...@@ -2795,10 +2799,11 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2795,10 +2799,11 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
if title: if title:
if not re.match(r'^[\w ]+$', title): if not re.match(r'^[\w ]+$', title):
title = re.sub(r'[^\w ]', '', title) title = re.sub(r'[^\w ]', '', title)
print('WARNING: Patchset title may only contain alphanumeric chars ' if not automatic_title:
'and spaces. Cleaned up title:\n%s' % title) print('WARNING: Patchset title may only contain alphanumeric chars '
if not options.force: 'and spaces. Cleaned up title:\n%s' % title)
ask_for_data('Press enter to continue, Ctrl+C to abort') 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 # Per doc, spaces must be converted to underscores, and Gerrit will do the
# reverse on its side. # reverse on its side.
refspec_opts.append('m=' + title.replace(' ', '_')) refspec_opts.append('m=' + title.replace(' ', '_'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment