devops: fix checkout re-use for multiple different base branches (#15231)

This commit is contained in:
Andrey Lushnikov 2022-06-29 08:30:39 -07:00 committed by GitHub
parent b3c31f5b13
commit 29c1ccd690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -189,6 +189,11 @@ else
git remote rename origin $REMOTE_BROWSER_UPSTREAM
fi
# Since we do a single-branch checkout by default, we might need to add a new remote base branch.
if ! git show-branch "remotes/$REMOTE_BROWSER_UPSTREAM/${BASE_BRANCH}" 2>&1 >/dev/null; then
git remote set-branches --add "$REMOTE_BROWSER_UPSTREAM" "${BASE_BRANCH}"
fi
# if our remote branch does not contains "BASE_REVISION" - then fetch more stuff.
if [[ -z $(git branch -r --contains "${BASE_REVISION}" --list "${REMOTE_BROWSER_UPSTREAM}/${BASE_BRANCH}") ]]; then
# Detach git head so that we can fetch into branch.