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

Side by Side Diff: gerrit_util.py

Issue 1922733002: Revert of Make `git cl description` work for Gerrit (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | git_cl.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 Utilities for requesting information for a gerrit server via https. 6 Utilities for requesting information for a gerrit server via https.
7 7
8 https://gerrit-review.googlesource.com/Documentation/rest-api.html 8 https://gerrit-review.googlesource.com/Documentation/rest-api.html
9 """ 9 """
10 10
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 523
524 524
525 def SubmitChange(host, change, wait_for_merge=True): 525 def SubmitChange(host, change, wait_for_merge=True):
526 """Submits a gerrit change via Gerrit.""" 526 """Submits a gerrit change via Gerrit."""
527 path = 'changes/%s/submit' % change 527 path = 'changes/%s/submit' % change
528 body = {'wait_for_merge': wait_for_merge} 528 body = {'wait_for_merge': wait_for_merge}
529 conn = CreateHttpConn(host, path, reqtype='POST', body=body) 529 conn = CreateHttpConn(host, path, reqtype='POST', body=body)
530 return ReadHttpJsonResponse(conn, ignore_404=False) 530 return ReadHttpJsonResponse(conn, ignore_404=False)
531 531
532 532
533 def SetCommitMessage(host, change, description):
534 """Updates a commit message."""
535 # First, edit the commit message in a draft.
536 path = 'changes/%s/edit:message' % change
537 body = {'message': description}
538 conn = CreateHttpConn(host, path, reqtype='PUT', body=body)
539 try:
540 ReadHttpResponse(conn, ignore_404=False)
541 except GerritError as e:
542 # On success, gerrit returns status 204; anything else is an error.
543 if e.http_status != 204:
544 raise
545 else:
546 raise GerritError(
547 'Unexpectedly received a 200 http status while editing message in '
548 'change %s' % change)
549
550 # And then publish it.
551 path = 'changes/%s/edit:publish' % change
552 conn = CreateHttpConn(host, path, reqtype='POST', body={})
553 try:
554 ReadHttpResponse(conn, ignore_404=False)
555 except GerritError as e:
556 # On success, gerrit returns status 204; anything else is an error.
557 if e.http_status != 204:
558 raise
559 else:
560 raise GerritError(
561 'Unexpectedly received a 200 http status while publishing message '
562 'change in %s' % change)
563
564
565 def GetReviewers(host, change): 533 def GetReviewers(host, change):
566 """Get information about all reviewers attached to a change.""" 534 """Get information about all reviewers attached to a change."""
567 path = 'changes/%s/reviewers' % change 535 path = 'changes/%s/reviewers' % change
568 return ReadHttpJsonResponse(CreateHttpConn(host, path)) 536 return ReadHttpJsonResponse(CreateHttpConn(host, path))
569 537
570 538
571 def GetReview(host, change, revision): 539 def GetReview(host, change, revision):
572 """Get review information about a specific revision of a change.""" 540 """Get review information about a specific revision of a change."""
573 path = 'changes/%s/revisions/%s/review' % (change, revision) 541 path = 'changes/%s/revisions/%s/review' % (change, revision)
574 return ReadHttpJsonResponse(CreateHttpConn(host, path)) 542 return ReadHttpJsonResponse(CreateHttpConn(host, path))
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 username = review.get('email', jmsg.get('name', '')) 635 username = review.get('email', jmsg.get('name', ''))
668 raise GerritError(200, 'Unable to set %s label for user "%s"' 636 raise GerritError(200, 'Unable to set %s label for user "%s"'
669 ' on change %s.' % (label, username, change)) 637 ' on change %s.' % (label, username, change))
670 jmsg = GetChangeCurrentRevision(host, change) 638 jmsg = GetChangeCurrentRevision(host, change)
671 if not jmsg: 639 if not jmsg:
672 raise GerritError( 640 raise GerritError(
673 200, 'Could not get review information for change "%s"' % change) 641 200, 'Could not get review information for change "%s"' % change)
674 elif jmsg[0]['current_revision'] != revision: 642 elif jmsg[0]['current_revision'] != revision:
675 raise GerritError(200, 'While resetting labels on change "%s", ' 643 raise GerritError(200, 'While resetting labels on change "%s", '
676 'a new patchset was uploaded.' % change) 644 'a new patchset was uploaded.' % change)
OLDNEW
« 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