Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make asdf latest output consistent #1685

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/functions/versions.bash
Expand Up @@ -130,7 +130,7 @@ list_all_command() {
}

latest_command() {
DEFAULT_QUERY="[0-9]"
DEFAULT_QUERY="v?[0-9]"

local plugin_name=$1
local query=$2
Expand All @@ -155,17 +155,13 @@ latest_command() {
exit 1
fi
else
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest)
versions=$(list_all_command "$plugin_name" "$query" |
grep -ivE "(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-milestone|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" |
sed 's/^[[:space:]]\+//' |
tail -1)
if [ -z "${versions}" ]; then
version=$(_latest_version_helper "$plugin_name" "$query")
if [ -z "${version}" ]; then
exit 1
fi
fi

printf "%s\n" "$versions"
printf "%s\n" "$version"
}

latest_all() {
Expand All @@ -186,11 +182,7 @@ latest_all() {
version="unknown"
fi
else
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest)
version=$(list_all_command "$plugin_name" |
grep -ivE "(^Available version:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" |
sed 's/^[[:space:]]\+//' |
tail -1)
version=$(_latest_version_helper "$plugin_name")
if [ -z "${version}" ]; then
version="unknown"
fi
Expand Down Expand Up @@ -238,3 +230,11 @@ local_command() {
version_command local "$@"
fi
}

_latest_version_helper() {
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest/blob/fe8fb00d55d2fb8daca834214f7ac614f87c255f/bin/xxenv-latest#L85)
list_all_command "$@" |
grep -ivE "(^Available versions?:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+$|snapshot|master|-nightly)" |
sed 's/^[[:space:]]\+//' |
tail -1
}