Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1137)

Unified Diff: git_cl.py

Issue 2318903002: Prompt to delete pending edits before changing the Gerrit CL description. (Closed)
Patch Set: CL comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gerrit_util.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 07c528c36f55f38af2af6d12f03a1f81dcbe0238..c6d283c3c56d6c21b234ab0956548be4ce9406a6 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1393,9 +1393,10 @@ class Changelist(object):
author,
upstream=upstream_branch)
- def UpdateDescription(self, description):
+ def UpdateDescription(self, description, force=False):
self.description = description
- return self._codereview_impl.UpdateDescriptionRemote(description)
+ return self._codereview_impl.UpdateDescriptionRemote(
+ description, force=force)
def RunHook(self, committing, may_prompt, verbose, change):
"""Calls sys.exit() if the hook fails; returns a HookResults otherwise."""
@@ -1603,7 +1604,7 @@ class _ChangelistCodereviewBase(object):
# None is valid return value, otherwise presubmit_support.GerritAccessor.
return None
- def UpdateDescriptionRemote(self, description):
+ def UpdateDescriptionRemote(self, description, force=False):
"""Update the description on codereview site."""
raise NotImplementedError()
@@ -1798,7 +1799,7 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase):
return 'reply'
return 'waiting'
- def UpdateDescriptionRemote(self, description):
+ def UpdateDescriptionRemote(self, description, force=False):
return self.RpcServer().update_description(
self.GetIssue(), self.description)
@@ -2294,7 +2295,17 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
url = data['revisions'][current_rev]['fetch']['http']['url']
return gerrit_util.GetChangeDescriptionFromGitiles(url, current_rev)
- def UpdateDescriptionRemote(self, description):
+ def UpdateDescriptionRemote(self, description, force=False):
+ if gerrit_util.HasPendingChangeEdit(self._GetGerritHost(), self.GetIssue()):
+ if not force:
+ ask_for_data(
+ 'The description cannot be modified while the issue has a pending '
+ 'unpublished edit. Either publish the edit in the Gerrit web UI '
+ 'or delete it.\n\n'
+ 'Press Enter to delete the unpublished edit, Ctrl+C to abort.')
+
+ gerrit_util.DeletePendingChangeEdit(self._GetGerritHost(),
+ self.GetIssue())
gerrit_util.SetCommitMessage(self._GetGerritHost(), self.GetIssue(),
description)
@@ -3607,6 +3618,9 @@ def CMDdescription(parser, args):
parser.add_option('-n', '--new-description',
help='New description to set for this issue (- for stdin, '
'+ to load from local commit HEAD)')
+ parser.add_option('-f', '--force', action='store_true',
+ help='Delete any unpublished Gerrit edits for this issue '
+ 'without prompting')
_add_codereview_select_options(parser)
auth.add_auth_options(parser)
@@ -3655,7 +3669,7 @@ def CMDdescription(parser, args):
description.prompt()
if cl.GetDescription() != description.description:
- cl.UpdateDescription(description.description)
+ cl.UpdateDescription(description.description, force=options.force)
return 0
« no previous file with comments | « gerrit_util.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698