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

Unified Diff: gerrit_util.py

Issue 1917473002: Make `git cl description` work for Gerrit (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: type Created 4 years, 8 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 53dc69c0c6d2806231e86f97e520faa7edb0e9ee..727626fe08c9cc3a40c6a456d96ec8abfeda190b 100755
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -530,6 +530,38 @@ def SubmitChange(host, change, wait_for_merge=True):
return ReadHttpJsonResponse(conn, ignore_404=False)
+def SetCommitMessage(host, change, description):
+ """Updates a commit message."""
+ # First, edit the commit message in a draft.
+ path = 'changes/%s/edit:message' % change
+ body = {'message': description}
+ conn = CreateHttpConn(host, path, reqtype='PUT', body=body)
+ 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
+ else:
+ raise GerritError(
+ 'Unexpectedly received a 200 http status while editing message in '
+ 'change %s' % change)
+
+ # And then publish it.
+ path = 'changes/%s/edit:publish' % change
+ conn = CreateHttpConn(host, path, reqtype='POST', body={})
+ 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
+ else:
+ raise GerritError(
+ 'Unexpectedly received a 200 http status while publishing message '
+ 'change in %s' % change)
+
+
def GetReviewers(host, change):
"""Get information about all reviewers attached to a change."""
path = 'changes/%s/reviewers' % change
« 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