[git-cl] refactor Change-Id manipulation in squash upload mode.

R=iannucci@chromium.org

Bug:

Change-Id: Ia1729175c9f10d7c89388bf1e227904e76cbb16c
Reviewed-on: https://chromium-review.googlesource.com/482319
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
changes/19/482319/2
Andrii Shyshkalov 9 years ago committed by Commit Bot
parent db02dd0524
commit 8c90d03fb9

@ -2875,6 +2875,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
if options.title: if options.title:
message = options.title + '\n\n' + message message = options.title + '\n\n' + message
change_desc = ChangeDescription(message) change_desc = ChangeDescription(message)
if not options.force: if not options.force:
change_desc.prompt(bug=options.bug) change_desc.prompt(bug=options.bug)
# On first upload, patchset title is always this string, while # On first upload, patchset title is always this string, while
@ -2883,16 +2884,15 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
automatic_title = True automatic_title = True
if not change_desc.description: if not change_desc.description:
DieWithError("Description is empty. Aborting...") DieWithError("Description is empty. Aborting...")
message = change_desc.description change_ids = git_footers.get_footer_change_id(change_desc.description)
change_ids = git_footers.get_footer_change_id(message)
if len(change_ids) > 1: if len(change_ids) > 1:
DieWithError('too many Change-Id footers, at most 1 allowed.') DieWithError('too many Change-Id footers, at most 1 allowed.')
if not change_ids: if not change_ids:
# Generate the Change-Id automatically. # Generate the Change-Id automatically.
message = git_footers.add_footer_change_id( change_desc.set_description(git_footers.add_footer_change_id(
message, GenerateGerritChangeId(message)) change_desc.description,
change_desc.set_description(message) GenerateGerritChangeId(change_desc.description)))
change_ids = git_footers.get_footer_change_id(message) change_ids = git_footers.get_footer_change_id(change_desc.description)
assert len(change_ids) == 1 assert len(change_ids) == 1
change_id = change_ids[0] change_id = change_ids[0]

Loading…
Cancel
Save