Merge pull request #16891 from Homebrew/update_reset_tag

cmd/update-reset: use stable tag.
This commit is contained in:
Mike McQuaid 2024-03-14 16:51:50 +00:00 committed by GitHub
commit 5012e2d17c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 "refs/tags/${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
}