Commit 9f29465e authored by Edward Lemur's avatar Edward Lemur Committed by LUCI CQ

git-cl: Refactor CMDUploadChange

Changes:
- Add _GetDescriptionForUpload and _GetTitleForUpload.
- Add ensure_change_id to ChangeDescription, that ensures the
  description has a particular Change-Id.
- If more than a Change-Id was entered on new issue upload, remove
  all, and add a new one.

Change-Id: I0eae474eb07ea3036973b18571f72a80da425b21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2101811Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 06c8bce1
This diff is collapsed.
......@@ -868,17 +868,6 @@ class TestGitCl(unittest.TestCase):
self.mockGit.config['gerrit.override-squash-uploads'] = (
'true' if squash_mode == 'override_squash' else 'false')
# If issue is given, then description is fetched from Gerrit instead.
if issue is None:
if squash:
title = 'Initial_upload'
else:
if not title:
calls += [
((['git', 'show', '-s', '--format=%s', 'HEAD'],), ''),
(('ask_for_data', 'Title for patchset []: '), 'User input'),
]
title = 'User_input'
if not git_footers.get_footer_change_id(description) and not squash:
calls += [
(('DownloadGerritHook', False), ''),
......@@ -945,6 +934,17 @@ class TestGitCl(unittest.TestCase):
ref_suffix = '%notify=NONE'
metrics_arguments.append('notify=NONE')
# If issue is given, then description is fetched from Gerrit instead.
if issue is None:
if squash:
title = 'Initial_upload'
else:
if not title:
calls += [
((['git', 'show', '-s', '--format=%s', 'HEAD'],), ''),
(('ask_for_data', 'Title for patchset []: '), 'User input'),
]
title = 'User_input'
if title:
ref_suffix += ',m=' + title
metrics_arguments.append('m')
......@@ -1297,7 +1297,7 @@ class TestGitCl(unittest.TestCase):
self._run_gerrit_upload_test(
['-r', 'foo@example.com', '--send-mail'],
'desc ✔\n\nBUG=\n\nChange-Id: I123456789',
['foo@example.com'],
reviewers=['foo@example.com'],
squash=False,
squash_mode='override_nosquash',
notify=True,
......
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