Commit 9c3a464b authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

For Gerrit: use CURRENT_COMMIT option to get description, not gitiles.

R=sergiyb@chromium.org
BUG=681704

Change-Id: I48804955d8e5e579eae6e60fccac304aaaa9230e
Reviewed-on: https://chromium-review.googlesource.com/430625Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent f732cd5c
......@@ -514,21 +514,6 @@ def GetChangeCommit(host, change, revision='current'):
return ReadHttpJsonResponse(CreateHttpConn(host, path))
def GetChangeDescriptionFromGitiles(url, revision):
"""Query Gitiles for actual commit message for a given url and ref.
url must be obtained from call to GetChangeDetail for a specific
revision (patchset) under 'fetch' key.
"""
parsed = urlparse.urlparse(url)
path = '%s/+/%s?format=json' % (parsed.path, revision)
# Note: Gerrit instances that Chrome infrastructure uses thus far have all
# enabled Gitiles, which allowes us to execute this call. This isn't true for
# all Gerrit instances out there. Thus, if line below fails, consider adding a
# fallback onto actually fetching ref from remote using pure git.
return ReadHttpJsonResponse(CreateHttpConn(parsed.netloc, path))['message']
def GetChangeCurrentRevision(host, change):
"""Get information about the latest revision for a given change."""
return QueryChanges(host, {}, change, o_params=('CURRENT_REVISION',))
......
......@@ -2462,10 +2462,9 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
return data['revisions'][data['current_revision']]['_number']
def FetchDescription(self):
data = self._GetChangeDetail(['CURRENT_REVISION'])
data = self._GetChangeDetail(['CURRENT_REVISION', 'CURRENT_COMMIT'])
current_rev = data['current_revision']
url = data['revisions'][current_rev]['fetch']['http']['url']
return gerrit_util.GetChangeDescriptionFromGitiles(url, current_rev)
return data['revisions'][current_rev]['commit']['message']
def UpdateDescriptionRemote(self, description, force=False):
if gerrit_util.HasPendingChangeEdit(self._GetGerritHost(), self.GetIssue()):
......
......@@ -200,7 +200,7 @@ class GerritAccessor(object):
try:
return gerrit_util.GetChangeDetail(
self.host, str(issue),
['ALL_REVISIONS', 'DETAILED_LABELS'],
['ALL_REVISIONS', 'DETAILED_LABELS', 'ALL_COMMITS'],
ignore_404=False)
except gerrit_util.GerritError as e:
if e.http_status == 404:
......@@ -240,12 +240,7 @@ class GerritAccessor(object):
rev = info['current_revision']
rev_info = info['revisions'][rev]
# Updates revision info, which is part of cached issue info.
if 'real_description' not in rev_info:
rev_info['real_description'] = (
gerrit_util.GetChangeDescriptionFromGitiles(
rev_info['fetch']['http']['url'], rev))
return rev_info['real_description']
return rev_info['commit']['message']
def GetChangeOwner(self, issue):
return self.GetChangeInfo(issue)['owner']['email']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment