Skip to content

Commit 01c8e42

Browse files
authored
Merge pull request #20190 from Homebrew/local-main-fix
cmd/update: ensure local branch moves to main
2 parents c3ec61b + 98b7bc8 commit 01c8e42

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Library/Homebrew/cmd/update.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,12 @@ EOS
252252
fi
253253

254254
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
255-
SOFT_DELETE_MASTER=
255+
MAIN_MIGRATION_REQUIRED=
256256
if [[ "${INITIAL_BRANCH}" == "master" &&
257257
("${DIR}" == "${HOMEBREW_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CASK_REPOSITORY}") ]]
258258
then
259259
# Migrate master to main for Homebrew/brew, homebrew-core or homebrew-cask
260-
INITIAL_BRANCH="main"
261-
SOFT_DELETE_MASTER="1"
260+
MAIN_MIGRATION_REQUIRED="1"
262261
fi
263262

264263
if [[ -n "${UPSTREAM_TAG}" ]] ||
@@ -326,7 +325,7 @@ EOS
326325

327326
if [[ -n "${HOMEBREW_NO_UPDATE_CLEANUP}" ]]
328327
then
329-
if [[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]] &&
328+
if [[ -z "${MAIN_MIGRATION_REQUIRED}" && "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]] &&
330329
[[ ! "${INITIAL_BRANCH}" =~ ^v[0-9]+\.[0-9]+\.[0-9]|stable$ ]]
331330
then
332331
git checkout "${INITIAL_BRANCH}" "${QUIET_ARGS[@]}"
@@ -337,7 +336,7 @@ EOS
337336
pop_stash_message
338337
fi
339338

340-
if [[ "${SOFT_DELETE_MASTER}" == 1 && -n "$(git config branch.main.remote 2>/dev/null || true)" ]]
339+
if [[ -n "${MAIN_MIGRATION_REQUIRED}" && -n "$(git config branch.main.remote 2>/dev/null || true)" ]]
341340
then
342341
git branch -d "${QUIET_ARGS[@]}" master
343342
fi

0 commit comments

Comments
 (0)