Commit 009150b7 authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

bot_update: be explicit when checking out branches.

$ git checkout <name>

may be interpreted by git as checking out a file named <name>
if <name> has slashes. Thus,

$ git checkout infra/config

ends up checking out infra/config directory of the (typically)
master branch that was checked out before. To avoid confusion,
we have to add '--' separator between branch name and file names:

$ git checkout <name> --

This in turns allows to run CQ-based presubmit on infra/config branches.

R=nodir@chromium.org

Bug: 790738
Change-Id: I6ce31a8f0fbd66fd59ac7c2ea9cccd3ff97d1f0e
Reviewed-on: https://chromium-review.googlesource.com/802136
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarNodir Turakulov <nodir@chromium.org>
parent 8076c285
......@@ -527,7 +527,7 @@ def force_solution_revision(solution_name, git_url, revisions, cwd):
branch, revision = _get_target_branch_and_revision(
solution_name, git_url, revisions)
if revision and revision.upper() != 'HEAD':
git('checkout', '--force', revision, cwd=cwd)
treeish = revision
else:
# TODO(machenbach): This won't work with branch-heads, as Gerrit's
# destination branch would be e.g. refs/branch-heads/123. But here
......@@ -535,8 +535,12 @@ def force_solution_revision(solution_name, git_url, revisions, cwd):
# This will also not work if somebody passes a local refspec like
# refs/heads/master. It needs to translate to refs/remotes/origin/master
# first. See also https://crbug.com/740456 .
ref = branch if branch.startswith('refs/') else 'origin/%s' % branch
git('checkout', '--force', ref, cwd=cwd)
treeish = branch if branch.startswith('refs/') else 'origin/%s' % branch
# Note that -- argument is necessary to ensure that git treats `treeish`
# argument as revision or ref, and not as a file/directory which happens to
# have the exact same name.
git('checkout', '--force', treeish, '--', cwd=cwd)
def is_broken_repo_dir(repo_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