Commit eadad92e authored by Andrii Shyshkalov's avatar Andrii Shyshkalov

git cl try: reduce number of RPCs to Gerrit from 3 to 1.

R=agable@chromium.org
BUG=681704

Change-Id: I3c0ab781e0357e0855d50157c5653df57f68ac9a
Reviewed-on: https://chromium-review.googlesource.com/432336Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
parent 8039be7c
......@@ -463,11 +463,6 @@ def _trigger_try_jobs(auth_config, changelist, buckets, options,
http = authenticator.authorize(httplib2.Http())
http.force_exception_to_status_code = True
# TODO(tandrii): consider caching Gerrit CL details just like
# _RietveldChangelistImpl does, then caching values in these two variables
# won't be necessary.
owner_email = changelist.GetIssueOwner()
buildbucket_put_url = (
'https://{hostname}/_ah/api/buildbucket/v1/builds/batch'.format(
hostname=options.buildbucket_host))
......@@ -498,7 +493,7 @@ def _trigger_try_jobs(auth_config, changelist, buckets, options,
parameters = {
'builder_name': builder,
'changes': [{
'author': {'email': owner_email},
'author': {'email': changelist.GetIssueOwner()},
'revision': options.revision,
}],
'properties': shared_parameters_properties.copy(),
......@@ -4722,6 +4717,10 @@ def CMDtry(parser, args):
if not cl.GetIssue():
parser.error('Need to upload first')
if cl.IsGerrit():
# HACK: warm up Gerrit change detail cache to save on RPCs.
cl._codereview_impl._GetChangeDetail(['DETAILED_ACCOUNTS', 'ALL_REVISIONS'])
error_message = cl.CannotTriggerTryJobReason()
if error_message:
parser.error('Can\'t trigger try jobs: %s' % error_message)
......
......@@ -2278,8 +2278,24 @@ class TestGitCl(TestCase):
((['git', 'config', 'branch.feature.gerritissue'],), '123456'),
((['git', 'config', 'branch.feature.gerritserver'],),
'https://chromium-review.googlesource.com'),
(('GetChangeDetail', 'chromium-review.googlesource.com', '123456', []),
{ 'status': 'OPEN' }),
(('GetChangeDetail', 'chromium-review.googlesource.com', '123456',
['DETAILED_ACCOUNTS', 'ALL_REVISIONS', 'CURRENT_COMMIT']), {
'project': 'depot_tools',
'status': 'OPEN',
'owner': {'email': 'owner@e.mail'},
'revisions': {
'deadbeaf': {
'_number': 6,
},
'beeeeeef': {
'_number': 7,
'fetch': {'http': {
'url': 'https://chromium.googlesource.com/depot_tools',
'ref': 'refs/changes/56/123456/7'
}},
},
},
}),
((['git', 'config', 'branch.feature.merge'],), 'feature'),
((['git', 'config', 'branch.feature.remote'],), 'origin'),
((['get_or_create_merge_base', 'feature', 'feature'],),
......@@ -2370,14 +2386,11 @@ class TestGitCl(TestCase):
((['git', 'config', 'branch.feature.gerritissue'],), '123456'),
((['git', 'config', 'branch.feature.gerritserver'],),
'https://chromium-review.googlesource.com'),
(('GetChangeDetail', 'chromium-review.googlesource.com', '123456', []),
{ 'status': 'OPEN' }),
(('GetChangeDetail', 'chromium-review.googlesource.com', '123456',
['DETAILED_ACCOUNTS']),
{'owner': {'email': 'owner@e.mail'}}),
(('GetChangeDetail', 'chromium-review.googlesource.com', '123456',
['ALL_REVISIONS', 'CURRENT_COMMIT']), {
['DETAILED_ACCOUNTS', 'ALL_REVISIONS', 'CURRENT_COMMIT']), {
'project': 'depot_tools',
'status': 'OPEN',
'owner': {'email': 'owner@e.mail'},
'revisions': {
'deadbeaf': {
'_number': 6,
......
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