use --key and --numeric-sort

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
This commit is contained in:
shcai97 2020-09-09 10:21:46 +08:00 committed by GitHub
parent 77f2a24a6b
commit 1789c27b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -430,8 +430,8 @@ EOS
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
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)"
sort --numeric-sort --field-separator=. --key=1,1 --key=2,2 --key=3,3 |
tail -n1)"
latest_ref="refs/tags/$latest_tag"
git fetch --force origin --shallow-since="$latest_ref"
fi