diff --git a/git_cl.py b/git_cl.py index 8856fd7ab2..839d2e556c 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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) diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 0cafc708a3..c622201f4a 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -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,