Commit 90b4c0f7 authored by Anthony Polito's avatar Anthony Polito Committed by LUCI CQ

add support for main in git_cache

Change-Id: I32dcd812b41518bd8e2ca50eae1862611ff577de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2528797Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Anthony Polito <apolito@google.com>
parent 9abde8c3
......@@ -475,10 +475,10 @@ class Mirror(object):
self._fetch(self.mirror_path, verbose, depth, no_fetch_tags,
reset_fetch_config)
def update_bootstrap(self, prune=False, gc_aggressive=False):
def update_bootstrap(self, prune=False, gc_aggressive=False, branch='master'):
# The folder is <git number>
gen_number = subprocess.check_output(
[self.git_exe, 'number', 'master'],
[self.git_exe, 'number', branch],
cwd=self.mirror_path).decode('utf-8', 'ignore').strip()
gsutil = Gsutil(path=self.gsutil_exe, boto_path=None)
......@@ -598,6 +598,8 @@ def CMDupdate_bootstrap(parser, args):
help='Run aggressive repacking of the repo.')
parser.add_option('--prune', action='store_true',
help='Prune all other cached bundles of the same repo.')
parser.add_option('--branch', default='master',
help='Branch to use for bootstrap. (Default \'master\')')
populate_args = args[:]
options, args = parser.parse_args(args)
......@@ -612,7 +614,7 @@ def CMDupdate_bootstrap(parser, args):
_, args2 = parser.parse_args(args)
url = args2[0]
mirror = Mirror(url)
mirror.update_bootstrap(options.prune, options.gc_aggressive)
mirror.update_bootstrap(options.prune, options.gc_aggressive, options.branch)
return 0
......
......@@ -42,6 +42,12 @@ class GitCacheTest(unittest.TestCase):
def testParseFetchSpec(self):
testData = [
([], []),
(['main'], [('+refs/heads/main:refs/heads/main',
r'\+refs/heads/main:.*')]),
(['main/'], [('+refs/heads/main:refs/heads/main',
r'\+refs/heads/main:.*')]),
(['+main'], [('+refs/heads/main:refs/heads/main',
r'\+refs/heads/main:.*')]),
(['master'], [('+refs/heads/master:refs/heads/master',
r'\+refs/heads/master:.*')]),
(['master/'], [('+refs/heads/master:refs/heads/master',
......
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