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

Unified Diff: gerrit_util.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 | « no previous file | git_cl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gerrit_util.py
diff --git a/gerrit_util.py b/gerrit_util.py
index 77fcb07c4ceaa143193759c52073cf8a8152f00a..011606f652fd7e6dc961057d6d4b89aa1dad6aa8 100755
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -545,6 +545,30 @@ def SubmitChange(host, change, wait_for_merge=True):
return ReadHttpJsonResponse(conn, ignore_404=False)
+def HasPendingChangeEdit(host, change):
+ conn = CreateHttpConn(host, 'changes/%s/edit' % change)
+ try:
+ ReadHttpResponse(conn, ignore_404=False)
+ except GerritError as e:
+ # On success, gerrit returns status 204; anything else is an error.
+ if e.http_status != 204:
+ raise
+ return False
+ else:
+ return True
+
+
+def DeletePendingChangeEdit(host, change):
+ conn = CreateHttpConn(host, 'changes/%s/edit' % change, reqtype='DELETE')
+ try:
+ ReadHttpResponse(conn, ignore_404=False)
+ except GerritError as e:
+ # On success, gerrit returns status 204; if the edit was already deleted it
+ # returns 404. Anything else is an error.
+ if e.http_status not in (204, 404):
+ raise
+
+
def SetCommitMessage(host, change, description):
"""Updates a commit message."""
# First, edit the commit message in a draft.
« no previous file with comments | « no previous file | git_cl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698