Generate patchset name from commit subject

BUG=672332

Change-Id: If9c662f11b217a52cac7c9c47ad9f3d978148c2e
Reviewed-on: https://chromium-review.googlesource.com/419330
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
changes/30/419330/4
Aaron Gable 9 years ago committed by Commit Bot
parent e9373d6e92
commit 947f2ee808

@ -2934,16 +2934,20 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
print('Adding self-LGTM (Code-Review +1) because of TBRs') print('Adding self-LGTM (Code-Review +1) because of TBRs')
refspec_opts.append('l=Code-Review+1') refspec_opts.append('l=Code-Review+1')
if options.title: title = options.title
if not re.match(r'^[\w ]+$', options.title): if not title:
options.title = re.sub(r'[^\w ]', '', options.title) default = RunGit(['show', '-s', '--format=%s', 'HEAD']).strip()
title = ask_for_data('Title for patchset [%s]: ' % default) or default
if title:
if not re.match(r'^[\w ]+$', title):
title = re.sub(r'[^\w ]', '', title)
print('WARNING: Patchset title may only contain alphanumeric chars ' 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: if not options.force:
ask_for_data('Press enter to continue, Ctrl+C to abort') 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=' + options.title.replace(' ', '_')) refspec_opts.append('m=' + title.replace(' ', '_'))
if options.send_mail: if options.send_mail:
if not change_desc.get_reviewers(): if not change_desc.get_reviewers():

@ -1338,7 +1338,7 @@ class TestGitCl(TestCase):
def _gerrit_upload_calls(cls, description, reviewers, squash, def _gerrit_upload_calls(cls, description, reviewers, squash,
squash_mode='default', squash_mode='default',
expected_upstream_ref='origin/refs/heads/master', 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): post_amend_description=None, issue=None, cc=None):
if post_amend_description is None: if post_amend_description is None:
post_amend_description = description post_amend_description = description
@ -1409,6 +1409,18 @@ class TestGitCl(TestCase):
expected_upstream_ref + '..' + ref_to_push],), ''), expected_upstream_ref + '..' + ref_to_push],), ''),
] ]
if not title:
calls += [
((['git', 'show', '-s', '--format=%s', 'HEAD'],), ''),
(('Title for patchset []: ',), ''),
]
else:
if ref_suffix:
ref_suffix += ',m=' + title
else:
ref_suffix = '%m=' + title
notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE') notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE')
if ref_suffix: if ref_suffix:
ref_suffix += ',' + notify_suffix ref_suffix += ',' + notify_suffix
@ -1462,6 +1474,7 @@ class TestGitCl(TestCase):
squash_mode=None, squash_mode=None,
expected_upstream_ref='origin/refs/heads/master', expected_upstream_ref='origin/refs/heads/master',
ref_suffix='', ref_suffix='',
title=None,
notify=False, notify=False,
post_amend_description=None, post_amend_description=None,
issue=None, issue=None,
@ -1494,7 +1507,7 @@ class TestGitCl(TestCase):
description, reviewers, squash, description, reviewers, squash,
squash_mode=squash_mode, squash_mode=squash_mode,
expected_upstream_ref=expected_upstream_ref, 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, post_amend_description=post_amend_description,
issue=issue, cc=cc) issue=issue, cc=cc)
# Uncomment when debugging. # Uncomment when debugging.
@ -1534,7 +1547,7 @@ class TestGitCl(TestCase):
'desc\n\nBUG=\n\nChange-Id: I123456789', 'desc\n\nBUG=\n\nChange-Id: I123456789',
squash=False, squash=False,
squash_mode='override_nosquash', squash_mode='override_nosquash',
ref_suffix='%m=Dont_put_bad_chars') title='Dont_put_bad_chars')
self.assertIn( self.assertIn(
'WARNING: Patchset title may only contain alphanumeric chars ' 'WARNING: Patchset title may only contain alphanumeric chars '
'and spaces. Cleaned up title:\nDont put bad chars\n', 'and spaces. Cleaned up title:\nDont put bad chars\n',

Loading…
Cancel
Save