Commit d9fdc1f5 authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

git cl: save description before doing any RPCs during upload.

R=smut@google.com

Bug: 881860
Change-Id: I59c337384891f02dbd2cc776318803ac556843ca
Reviewed-on: https://chromium-review.googlesource.com/1247584Reviewed-by: 's avatarsmut <smut@google.com>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent f221bac5
......@@ -107,8 +107,7 @@ def DieWithError(message, change_desc=None):
def SaveDescriptionBackup(change_desc):
backup_path = os.path.expanduser(DESCRIPTION_BACKUP_FILE)
print('\nError after CL description prompt -- saving description to %s\n' %
backup_path)
print('\nsaving CL description to %s\n' % backup_path)
backup_file = open(backup_path, 'w')
backup_file.write(change_desc.description)
backup_file.close()
......@@ -3014,6 +3013,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
change_id = git_footers.get_footer_change_id(change_desc.description)[0]
assert change_desc
SaveDescriptionBackup(change_desc)
commits = RunGitSilent(['rev-list', '%s..%s' % (parent,
ref_to_push)]).splitlines()
if len(commits) > 1:
......
......@@ -661,6 +661,8 @@ class TestGitCl(TestCase):
self._mocked_call(['get_or_create_merge_base']+list(a))))
self.mock(git_cl, 'BranchExists', lambda _: True)
self.mock(git_cl, 'FindCodereviewSettingsFile', lambda: '')
self.mock(git_cl, 'SaveDescriptionBackup', lambda _:
self._mocked_call('SaveDescriptionBackup'))
self.mock(git_cl, 'ask_for_data', lambda *a, **k: self._mocked_call(
*(['ask_for_data'] + list(a)), **k))
self.mock(git_cl, 'write_json', lambda path, contents:
......@@ -1240,6 +1242,7 @@ class TestGitCl(TestCase):
ref_to_push = 'HEAD'
calls += [
(('SaveDescriptionBackup',), None),
((['git', 'rev-list',
(custom_cl_base if custom_cl_base else expected_upstream_ref) + '..' +
ref_to_push],),
......
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