From 98b7bc8d11ae64c9581bdfdbbdbc443b6f8097df Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Fri, 27 Jun 2025 22:05:17 +0100 Subject: [PATCH] cmd/update: ensure local branch moves to main --- Library/Homebrew/cmd/update.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 5f6c68fb6d..f8e1818e22 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -252,13 +252,12 @@ EOS fi INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)" - SOFT_DELETE_MASTER= + MAIN_MIGRATION_REQUIRED= if [[ "${INITIAL_BRANCH}" == "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 - INITIAL_BRANCH="main" - SOFT_DELETE_MASTER="1" + MAIN_MIGRATION_REQUIRED="1" fi if [[ -n "${UPSTREAM_TAG}" ]] || @@ -326,7 +325,7 @@ EOS if [[ -n "${HOMEBREW_NO_UPDATE_CLEANUP}" ]] then - if [[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]] && + if [[ -z "${MAIN_MIGRATION_REQUIRED}" && "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]] && [[ ! "${INITIAL_BRANCH}" =~ ^v[0-9]+\.[0-9]+\.[0-9]|stable$ ]] then git checkout "${INITIAL_BRANCH}" "${QUIET_ARGS[@]}" @@ -337,7 +336,7 @@ EOS pop_stash_message fi - if [[ "${SOFT_DELETE_MASTER}" == 1 && -n "$(git config branch.main.remote 2>/dev/null || true)" ]] + if [[ -n "${MAIN_MIGRATION_REQUIRED}" && -n "$(git config branch.main.remote 2>/dev/null || true)" ]] then git branch -d "${QUIET_ARGS[@]}" master fi