From f649587d51491eb8a86407ef5edeea89a9e740a1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jun 2025 12:11:11 +0100 Subject: [PATCH] cmd/update: improve Homebrew/brew `main` migration. Let's avoid people sticking on the `master` branch unnecessarily. --- Library/Homebrew/cmd/update.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 21bea55af7..a903dd1838 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -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 @@ -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 }