Force set HEAD to refs/heads/main for git_cache

We only build git_cache if main branch exists, and newly boostrap caches
have main as default. This sets HEAD for already boostrapped caches, in
case they were boostrapped before the default branch change.

R=gavinmak@google.com

Bug: 1251783
Change-Id: I715329ee06cf523f9fe2e6a324381dc5703bac34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3218281
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
changes/81/3218281/2
Josip Sokcevic 4 years ago committed by LUCI CQ
parent 0bce062fb3
commit 13225b70bc

@ -390,6 +390,10 @@ class Mirror(object):
if depth and os.path.exists(os.path.join(self.mirror_path, 'shallow')):
logging.warning(
'Shallow fetch requested, but repo cache already exists.')
# Old boostraps may have old default HEAD, so this ensures main is always
# used.
self.RunGit(['symbolic-ref', 'HEAD', 'refs/heads/main'],
cwd=self.mirror_path)
return
if not self.exists():

Loading…
Cancel
Save