bot_update: Don't checkout 'master' after clone.

Checkout 'HEAD' instead. This is needed to have a detached HEAD, so we
can fetch refs/heads/main:refs/heads/main, where main is the default
branch.

Bug: 1104182
Change-Id: I7b7457b21b7d98d29583555b62e27e96e900adb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2300533
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
changes/33/2300533/7
Edward Lesmes 5 years ago committed by LUCI CQ
parent d4e20f24d5
commit ed9e5acd61

@ -771,8 +771,11 @@ def _git_checkout(sln, sln_dir, revisions, refs, no_fetch_tags, git_cache_dir,
if not path.isdir(sln_dir):
git('clone', '--no-checkout', '--local', '--shared', mirror_dir,
sln_dir)
# Detach HEAD to be consistent with the non-clone case
git('checkout', 'master', '--detach', cwd=sln_dir)
# When bot_update clones a git repository, it results in HEAD referring
# to master in contrast with the non-clone case, which results in a
# detached HEAD. This prevents fetching the default branch so detach the
# HEAD after cloning.
git('checkout', 'HEAD', '--detach', cwd=sln_dir)
_git_disable_gc(sln_dir)
else:
_git_disable_gc(sln_dir)

Loading…
Cancel
Save