cmd/update: improve Homebrew/brew main migration.

Let's avoid people sticking on the `master` branch unnecessarily.
This commit is contained in:
Mike McQuaid 2025-06-26 12:11:11 +01:00
parent dfe8fde704
commit f649587d51
No known key found for this signature in database

View File

@ -252,6 +252,14 @@ EOS
fi fi
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)" 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}" ]] || if [[ -n "${UPSTREAM_TAG}" ]] ||
[[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]] [[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]]
then then
@ -328,6 +336,11 @@ EOS
pop_stash_message pop_stash_message
fi 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 trap - SIGINT
} }