Commit f0faf48d authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

git-cl: Set legacy properties.

Will be removed back again on Oct 9, 2019.

Bug: 1004447
Change-Id: I7003fac9ae8b184e2a7073b516535e8fd599f4f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1825446
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@google.com>
parent 69b63c9f
......@@ -455,10 +455,9 @@ def _trigger_try_jobs(auth_config, changelist, buckets, options, patchset):
print('To see results here, run: git cl try-results')
print('To see results in browser, run: git cl web')
gerrit_changes = [changelist.GetGerritChange()]
shared_properties = {
'category': options.category,
}
gerrit_changes = [changelist.GetGerritChange(patchset)]
shared_properties = {'category': options.category}
shared_properties.update(changelist.GetLegacyProperties(patchset))
if options.clobber:
shared_properties['clobber'] = True
shared_properties.update(_get_properties_from_options(options) or {})
......@@ -2686,6 +2685,34 @@ class Changelist(object):
if data['status'] in ('ABANDONED', 'MERGED'):
return 'CL %s is closed' % self.GetIssue()
# TODO(1004447): Remove on Oct 9th, 2019.
def GetLegacyProperties(self, patchset=None):
host = self.GetCodereviewServer()
issue = self.GetIssue()
patchset = int(patchset or self.GetPatchset())
data = self._GetChangeDetail(['ALL_REVISIONS'])
assert host and issue and patchset, 'CL must be uploaded first'
revision_data = None # Pylint wants it to be defined.
for revision_data in data['revisions'].itervalues():
if int(revision_data['_number']) == patchset:
break
else:
raise Exception('Patchset %d is not known in Gerrit change %d' %
(patchset, issue))
return {
'patch_issue': issue,
'patch_set': patchset,
'patch_project': data['project'],
'patch_storage': 'gerrit',
'patch_ref': revision_data['fetch']['http']['ref'],
'patch_repository_url': revision_data['fetch']['http']['url'],
'patch_gerrit_url': host,
}
def GetGerritChange(self, patchset=None):
"""Returns a buildbucket.v2.GerritChange message for the current issue."""
host = urlparse.urlparse(self.GetCodereviewServer()).hostname
......
......@@ -3218,6 +3218,15 @@ class CMDTryTestCase(unittest.TestCase):
"category": "git_cl_try",
"json": [{"a": 1}, None],
"key": "val",
'patch_issue': 123456,
'patch_set': 7,
'patch_project': 'depot_tools',
'patch_storage': 'gerrit',
'patch_ref': 'refs/changes/56/123456/7',
'patch_repository_url':
'https://chromium.googlesource.com/depot_tools',
'patch_gerrit_url':
'https://chromium-review.googlesource.com',
},
"tags": [
{"value": "win", "key": "builder"},
......
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