Commit e8856eea authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

git-cl: fix 'status --field=patch' for Gerrit

We don't set the branch.<name>.gerritpatchset git config value
during "git cl upload" because it isn't returned from the
server either during push or during any of our subsequent RPCs,
and adding another RPC just for that metadata would be slower
that we would like.

But calling "git cl status" already makes an RPC per branch, so
take advantage of that to cache the gerritpatchset value during
that operation.

R=robertma

Bug: 792611
Change-Id: I37b09f3c4cfced86668b457eff82f2424012b14b
Reviewed-on: https://chromium-review.googlesource.com/815137Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
parent fa4112f5
......@@ -2574,7 +2574,9 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
def GetMostRecentPatchset(self):
data = self._GetChangeDetail(['CURRENT_REVISION'])
return data['revisions'][data['current_revision']]['_number']
patchset = data['revisions'][data['current_revision']]['_number']
self.SetPatchset(patchset)
return patchset
def FetchDescription(self, force=False):
data = self._GetChangeDetail(['CURRENT_REVISION', 'CURRENT_COMMIT'],
......@@ -4427,7 +4429,7 @@ def CMDstatus(parser, args):
if issueid:
print(issueid)
elif options.field == 'patch':
patchset = cl.GetPatchset()
patchset = cl.GetMostRecentPatchset()
if patchset:
print(patchset)
elif options.field == 'status':
......
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