Set HEAD on repo init, not after downloading repo

git_cache incorrectly sets HEAD to main. It should be done during repo
initialization, and not after files are downloaded. Current
implementation overrides HEAD settings instead of keping whatever is on
remote.

R=aravindvasudev@google.com

Fixed: 1475252
Change-Id: Idba87e2774ecbf249630a207d284f91c0f4a8a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4820461
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
changes/61/4820461/2
Josip Sokcevic 2 years ago committed by LUCI CQ
parent e40f71cbde
commit 5146d78ee5

@ -305,7 +305,7 @@ class Mirror(object):
try:
# create new temporary directory locally
tempdir = tempfile.mkdtemp(prefix='_cache_tmp', dir=self.GetCachePath())
self.RunGit(['init', '--bare'], cwd=tempdir)
self.RunGit(['init', '-b', 'main', '--bare'], cwd=tempdir)
self.print('Downloading files in %s/* into %s.' %
(latest_dir, tempdir))
with self.print_duration_of('download'):
@ -314,8 +314,6 @@ class Mirror(object):
tempdir)
if code:
return False
# Set HEAD to main.
self.RunGit(['symbolic-ref', 'HEAD', 'refs/heads/main'], cwd=tempdir)
# A quick validation that all references are valid.
self.RunGit(['for-each-ref'], print_stdout=False, cwd=tempdir)
except Exception as e:

Loading…
Cancel
Save