Skip to content

Commit

Permalink
cmd/update-reset: use stable tag.
Browse files Browse the repository at this point in the history
Currently we always reset Homebrew/brew onto the latest `master`.
Instead, let's correctly use the latest tag when appropriate.
  • Loading branch information
MikeMcQuaid committed Mar 14, 2024
1 parent a7d7748 commit 19a0c3e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Library/Homebrew/cmd/update-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,21 @@ homebrew-update-reset() {
echo

ohai "Resetting ${DIR}..."
head="$(git -C "${DIR}" symbolic-ref refs/remotes/origin/HEAD)"
head="${head#refs/remotes/origin/}"
git -C "${DIR}" checkout --force -B "${head}" origin/HEAD
# HOMEBREW_* variables here may all set by bin/brew or the user
# shellcheck disable=SC2154
if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" &&
(-n "${HOMEBREW_UPDATE_TO_TAG}" ||
(-z "${HOMEBREW_DEVELOPER}" && -z "${HOMEBREW_DEV_CMD_RUN}")) ]]
then
local latest_git_tag
latest_git_tag="$(git -C "${DIR}" tag --list --sort="-version:refname" | head -n1)"

git -C "${DIR}" checkout --force -B stable "${latest_git_tag}"
else
head="$(git -C "${DIR}" symbolic-ref refs/remotes/origin/HEAD)"
head="${head#refs/remotes/origin/}"
git -C "${DIR}" checkout --force -B "${head}" origin/HEAD
fi
echo
done
}

0 comments on commit 19a0c3e

Please sign in to comment.