Merge pull request #20186 from Homebrew/origin-head-fix

cmd/update: ensure we update remote main ref
This commit is contained in:
Bo Anderson 2025-06-27 16:57:41 +00:00 committed by GitHub
commit 4dabf8da16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -252,6 +252,7 @@ EOS
fi
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
SOFT_DELETE_MASTER=
if [[ "${INITIAL_BRANCH}" == "master" &&
("${DIR}" == "${HOMEBREW_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CASK_REPOSITORY}") ]]
then
@ -682,6 +683,16 @@ EOS
UPSTREAM_REPOSITORY_TOKEN="${BASH_REMATCH[1]#*:}"
fi
MAIN_MIGRATION_REQUIRED=
if [[ "${UPSTREAM_BRANCH_DIR}" == "master" &&
("${DIR}" == "${HOMEBREW_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CASK_REPOSITORY}") ]]
then
# Migrate master to main for Homebrew/brew, homebrew-core or homebrew-cask
MAIN_MIGRATION_REQUIRED=1
UPSTREAM_BRANCH_DIR="main"
declare UPSTREAM_BRANCH"${TAP_VAR}"="main"
fi
if [[ -n "${UPSTREAM_REPOSITORY}" ]]
then
# UPSTREAM_REPOSITORY_TOKEN is parsed (if exists) from UPSTREAM_REPOSITORY_URL
@ -793,6 +804,11 @@ EOS
fi
fi
if [[ -n "${MAIN_MIGRATION_REQUIRED}" ]]
then
git remote set-head origin --auto >/dev/null
fi
rm -f "${tmp_failure_file}"
) &
done