Commit ed9e5acd authored by Edward Lesmes's avatar Edward Lesmes Committed by LUCI CQ

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: 's avatarJosip Sokcevic <sokcevic@google.com>
parent d4e20f24
......@@ -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)
......
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