Skip to content

cmd/update: improve Homebrew/brew and homebrew-cask main migration. #20175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ EOS
fi

INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
if [[ "${INITIAL_BRANCH}" == "master" &&
("${DIR}" == "${HOMEBREW_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CASK_REPOSITORY}") ]]
then
# Migrate master to main for Homebrew/brew or Homebrew/homebrew-cask
INITIAL_BRANCH="main"
SOFT_DELETE_MASTER="1"
fi

if [[ -n "${UPSTREAM_TAG}" ]] ||
[[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]]
then
Expand Down Expand Up @@ -328,6 +336,11 @@ EOS
pop_stash_message
fi

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

trap - SIGINT
}

Expand Down