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):
# 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,6 +2799,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
if title:
if not re.match(r'^[\w ]+$', title):
title = re.sub(r'[^\w ]', '', title)
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:
......
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