mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 09:38:16 -07:00
2ca517d8c1
latest tag from the list of sorted tags. The setup code for these tests isn't ideal. It would be nice not to have to worry about the remote. Without the 'origin' remote set the Travis build would fail though.
31 lines
821 B
Bash
31 lines
821 B
Bash
update_command() {
|
|
local update_to_head=$1
|
|
|
|
(
|
|
cd $(asdf_dir)
|
|
|
|
if [ "$update_to_head" = "--head" ]; then
|
|
# Update to latest on the master branch
|
|
git checkout master
|
|
|
|
# Pull down the latest changes on master
|
|
git pull origin master
|
|
echo "Updated asdf to latest on the master branch"
|
|
else
|
|
# Update to latest release
|
|
git fetch --tags || exit 1
|
|
tag=$(git tag | sort_versions | sed '$!d') || exit 1
|
|
|
|
# Update
|
|
git checkout "$tag" || exit 1
|
|
echo "Updated asdf to release $tag"
|
|
fi
|
|
)
|
|
}
|
|
|
|
# stolen from https://github.com/rbenv/ruby-build/pull/631/files#diff-fdcfb8a18714b33b07529b7d02b54f1dR942
|
|
sort_versions() {
|
|
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | \
|
|
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}'
|
|
}
|