Check PACKFILE_OFFLOADING env variable

If set, set git config fetch.uriprotocols to https. This will be
initially set by codesearch builders. Once tested, this env variable can
be removed.

R=ehmaldonaldo@chromium.org

Bug: 1136986
Change-Id: I1c3da87bdbc74d18585ed00ffdc2cf21b84b16fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2591808
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
changes/08/2591808/2
Josip Sokcevic 4 years ago committed by LUCI CQ
parent f1c7d0dd2d
commit d8fe52139f

@ -13,6 +13,7 @@ from contextlib import contextmanager
import copy import copy
import ctypes import ctypes
from datetime import datetime from datetime import datetime
import functools
import json import json
import optparse import optparse
import os import os
@ -676,6 +677,19 @@ def _maybe_break_locks(checkout_path, tries=3):
pass pass
def _set_git_config(fn):
@functools.wraps(fn)
def wrapper(*args, **kwargs):
with git_config_if_not_set('user.name', 'chrome-bot'), \
git_config_if_not_set('user.email', 'chrome-bot@chromium.org'):
if os.getenv('PACKFILE_OFFLOADING') == '1':
with git_config_if_not_set('fetch.uriprotocols', 'https'):
return fn(*args, **kwargs)
return fn(*args, **kwargs)
return wrapper
def git_checkouts(solutions, revisions, refs, no_fetch_tags, git_cache_dir, def git_checkouts(solutions, revisions, refs, no_fetch_tags, git_cache_dir,
cleanup_dir, enforce_fetch): cleanup_dir, enforce_fetch):
@ -864,6 +878,7 @@ def emit_json(out_file, did_run, gclient_output=None, **kwargs):
f.write(json.dumps(output, sort_keys=True)) f.write(json.dumps(output, sort_keys=True))
@_set_git_config
def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only,
target_cpu, patch_root, patch_refs, gerrit_rebase_patch_ref, target_cpu, patch_root, patch_refs, gerrit_rebase_patch_ref,
no_fetch_tags, refs, git_cache_dir, cleanup_dir, no_fetch_tags, refs, git_cache_dir, cleanup_dir,
@ -894,8 +909,6 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only,
for solution_name in list(solution_dirs): for solution_name in list(solution_dirs):
gc_revisions[solution_name] = 'unmanaged' gc_revisions[solution_name] = 'unmanaged'
with git_config_if_not_set('user.name', 'chrome-bot'), \
git_config_if_not_set('user.email', 'chrome-bot@chromium.org'):
# Let gclient do the DEPS syncing. # Let gclient do the DEPS syncing.
# The branch-head refspec is a special case because it's possible Chrome # The branch-head refspec is a special case because it's possible Chrome
# src, which contains the branch-head refspecs, is DEPSed in. # src, which contains the branch-head refspecs, is DEPSed in.

@ -196,6 +196,12 @@ class BotUpdateUnittests(unittest.TestCase):
bot_update.ensure_checkout(**self.params) bot_update.ensure_checkout(**self.params)
return self.call.records return self.call.records
def testBasicCachepackOffloading(self):
os.environ['PACKFILE_OFFLOADING'] = '1'
bot_update.ensure_checkout(**self.params)
os.environ.pop('PACKFILE_OFFLOADING')
return self.call.records
def testBasicRevision(self): def testBasicRevision(self):
self.params['revisions'] = { self.params['revisions'] = {
'src': 'HEAD', 'src/v8': 'deadbeef', 'somename': 'DNE'} 'src': 'HEAD', 'src/v8': 'deadbeef', 'somename': 'DNE'}

Loading…
Cancel
Save