Add support for RC versions to asdf update command

This commit is contained in:
Trevor Brown 2019-03-24 18:24:19 -04:00
parent c418eb5976
commit 85057b6969
3 changed files with 22 additions and 3 deletions

View File

@ -41,6 +41,7 @@ legacy_version_file = yes
**Settings**
- `legacy_version_file` - defaults to `no`. If set to yes it will cause plugins that support this feature to read the version files used by other version managers (e.g. `.ruby-version` in the case of Ruby's `rbenv`).
- `use_release_candidates` - defaults to `no`. If set to yes it will cause the `asdf update` command to upgrade to the latest release candidate release instead of the latest semantic version.
## Environment Variables

View File

@ -26,7 +26,14 @@ do_update() {
else
# Update to latest release
git fetch origin --tags || exit 1
if [ "$(get_asdf_config_value "use_release_candidates")" = "yes" ]; then
# Use the latest tag whether or not it is an RC
tag=$(git tag | sort_versions | sed '$!d') || exit 1
else
# Exclude RC tags when selecting latest tag
tag=$(git tag | sort_versions | grep -vi "rc" | sed '$!d') || exit 1
fi
# Update
git checkout "$tag" || exit 1

View File

@ -29,11 +29,22 @@ teardown() {
[ $(git rev-parse --abbrev-ref HEAD) = "master" ]
}
@test "update_command should checkout the latest tag" {
@test "update_command should checkout the latest non-RC tag" {
local tag=$(git tag | grep -vi "rc" | head -1)
run update_command
[ "$status" -eq 0 ]
cd $ASDF_DIR
echo $(git tag) | grep $tag
[ "$status" -eq 0 ]
}
@test "update_command should checkout the latest tag when configured with use_release_candidates = yes" {
local tag=$(git tag | head -1)
export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults
echo "use_release_candidates = yes" > $ASDF_CONFIG_DEFAULT_FILE
run update_command
[ "$status" -eq 0 ]
cd $ASDF_DIR
local tag=$(git describe --tag)
echo $(git tag) | grep $tag
[ "$status" -eq 0 ]
}