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

Side by Side Diff: gerrit_util.py

Issue 1916123002: Fetch Gerrit cl description from gitiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 477
478 def GetChangeDetail(host, change, o_params=None): 478 def GetChangeDetail(host, change, o_params=None):
479 """Query a gerrit server for extended information about a single change.""" 479 """Query a gerrit server for extended information about a single change."""
480 path = 'changes/%s/detail' % change 480 path = 'changes/%s/detail' % change
481 if o_params: 481 if o_params:
482 path += '?%s' % '&'.join(['o=%s' % p for p in o_params]) 482 path += '?%s' % '&'.join(['o=%s' % p for p in o_params])
483 return ReadHttpJsonResponse(CreateHttpConn(host, path)) 483 return ReadHttpJsonResponse(CreateHttpConn(host, path))
484 484
485 485
486 def GetChangeDescriptionFromGitiles(url, revision):
487 """Query Gitiles for actual commit message for a given url and ref.
488
489 url must be obtained from call to GetChangeDetail for a specific
490 revision (patchset) under 'fetch' key.
491 """
492 parsed = urlparse.urlparse(url)
493 path = '%s/+/%s?format=json' % (parsed.path, revision)
494 return ReadHttpJsonResponse(CreateHttpConn(parsed.netloc, path))['message']
495
496
486 def GetChangeCurrentRevision(host, change): 497 def GetChangeCurrentRevision(host, change):
487 """Get information about the latest revision for a given change.""" 498 """Get information about the latest revision for a given change."""
488 return QueryChanges(host, {}, change, o_params=('CURRENT_REVISION',)) 499 return QueryChanges(host, {}, change, o_params=('CURRENT_REVISION',))
489 500
490 501
491 def GetChangeRevisions(host, change): 502 def GetChangeRevisions(host, change):
492 """Get information about all revisions associated with a change.""" 503 """Get information about all revisions associated with a change."""
493 return QueryChanges(host, {}, change, o_params=('ALL_REVISIONS',)) 504 return QueryChanges(host, {}, change, o_params=('ALL_REVISIONS',))
494 505
495 506
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 username = review.get('email', jmsg.get('name', '')) 646 username = review.get('email', jmsg.get('name', ''))
636 raise GerritError(200, 'Unable to set %s label for user "%s"' 647 raise GerritError(200, 'Unable to set %s label for user "%s"'
637 ' on change %s.' % (label, username, change)) 648 ' on change %s.' % (label, username, change))
638 jmsg = GetChangeCurrentRevision(host, change) 649 jmsg = GetChangeCurrentRevision(host, change)
639 if not jmsg: 650 if not jmsg:
640 raise GerritError( 651 raise GerritError(
641 200, 'Could not get review information for change "%s"' % change) 652 200, 'Could not get review information for change "%s"' % change)
642 elif jmsg[0]['current_revision'] != revision: 653 elif jmsg[0]['current_revision'] != revision:
643 raise GerritError(200, 'While resetting labels on change "%s", ' 654 raise GerritError(200, 'While resetting labels on change "%s", '
644 'a new patchset was uploaded.' % change) 655 '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