Commit 9b713dd1 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

Generate patchset name from commit subject

This is a reland of 947f2ee8,
which was reverted in a5a1eea5

BUG=672332

Change-Id: If33c54e500fbeac11f60d81a19549880506c63d8
Reviewed-on: https://chromium-review.googlesource.com/419737Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
parent 49fe922f
......@@ -2934,16 +2934,24 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
print('Adding self-LGTM (Code-Review +1) because of TBRs')
refspec_opts.append('l=Code-Review+1')
if options.title:
if not re.match(r'^[\w ]+$', options.title):
options.title = re.sub(r'[^\w ]', '', options.title)
title = options.title
if not title:
if self.GetIssue():
# We already have an issue, so we should ask for a title for new patch.
default = RunGit(['show', '-s', '--format=%s', 'HEAD']).strip()
title = ask_for_data('Title for patchset [%s]: ' % default) or default
else:
title = 'Initial upload'
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' % options.title)
'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=' + options.title.replace(' ', '_'))
refspec_opts.append('m=' + title.replace(' ', '_'))
if options.send_mail:
if not change_desc.get_reviewers():
......
......@@ -1364,7 +1364,7 @@ class TestGitCl(TestCase):
def _gerrit_upload_calls(cls, description, reviewers, squash,
squash_mode='default',
expected_upstream_ref='origin/refs/heads/master',
ref_suffix='', notify=False,
ref_suffix='', title=None, notify=False,
post_amend_description=None, issue=None, cc=None):
if post_amend_description is None:
post_amend_description = description
......@@ -1435,6 +1435,22 @@ class TestGitCl(TestCase):
expected_upstream_ref + '..' + ref_to_push],), ''),
]
if not title:
if issue:
calls += [
((['git', 'show', '-s', '--format=%s', 'HEAD'],), ''),
(('Title for patchset []: ',), 'User input'),
]
title = 'User_input'
else:
title = 'Initial_upload'
if title:
if ref_suffix:
ref_suffix += ',m=' + title
else:
ref_suffix = '%m=' + title
notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE')
if ref_suffix:
ref_suffix += ',' + notify_suffix
......@@ -1488,6 +1504,7 @@ class TestGitCl(TestCase):
squash_mode=None,
expected_upstream_ref='origin/refs/heads/master',
ref_suffix='',
title=None,
notify=False,
post_amend_description=None,
issue=None,
......@@ -1520,7 +1537,7 @@ class TestGitCl(TestCase):
description, reviewers, squash,
squash_mode=squash_mode,
expected_upstream_ref=expected_upstream_ref,
ref_suffix=ref_suffix, notify=notify,
ref_suffix=ref_suffix, title=title, notify=notify,
post_amend_description=post_amend_description,
issue=issue, cc=cc)
# Uncomment when debugging.
......@@ -1560,7 +1577,7 @@ class TestGitCl(TestCase):
'desc\n\nBUG=\n\nChange-Id: I123456789',
squash=False,
squash_mode='override_nosquash',
ref_suffix='%m=Dont_put_bad_chars')
title='Dont_put_bad_chars')
self.assertIn(
'WARNING: Patchset title may only contain alphanumeric chars '
'and spaces. Cleaned up title:\nDont put bad chars\n',
......
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