use sort to fix latest_tag

This commit is contained in:
shcai97 2020-09-09 01:12:58 +08:00
parent 249e8e29f9
commit 77f2a24a6b

View File

@ -428,8 +428,12 @@ EOS
echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote."
git remote set-url origin "$HOMEBREW_BREW_GIT_REMOTE"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
latest_tag="$(git ls-remote --tags --refs --sort=v:refname -q origin | tail -n1 | cut -f2)"
git fetch --force origin --shallow-since="$latest_tag"
latest_tag="$(git ls-remote --tags --refs -q origin |
cut -d/ -f3 |
sort --field-separator=. --key=1,1nr -k 2,2nr -k 3,3nr|
head -n1)"
latest_ref="refs/tags/$latest_tag"
git fetch --force origin --shallow-since="$latest_ref"
fi
if [[ "$HOMEBREW_CORE_DEFAULT_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]] &&