Skip to content

Commit

Permalink
Merge pull request #14 from MontakOleg/pre-release-versions-order
Browse files Browse the repository at this point in the history
fix: use versionsort.suffix to sort pre release versions before release
  • Loading branch information
pepicrft authored Feb 13, 2024
2 parents 44260bf + bffc9aa commit bffa4c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/latest-stable
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ redirect_url=$(curl "${curl_opts[@]}" "$GH_REPO/releases/latest" | sed -n -e "s|
version=
printf "redirect url: %s\n" "$redirect_url" >&2
if [[ "$redirect_url" == "$GH_REPO/releases" ]]; then
version="$(list_all_versions | sort_versions | tail -n1 | xargs echo)"
version="$(list_all_versions_sorted | tail -n1 | xargs echo)"
else
version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/v\{0,1\}||')"
fi
Expand Down
2 changes: 1 addition & 1 deletion bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ plugin_dir=$(dirname "$(dirname "$current_script_path")")
# shellcheck source=./lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

list_all_versions | sort_versions | xargs echo
list_all_versions_sorted | xargs echo
13 changes: 4 additions & 9 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@ if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
fi

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}'
}

list_github_tags() {
git ls-remote --tags --refs "$GH_REPO" |
list_github_tags_sorted() {
git -c 'versionsort.suffix=-beta' ls-remote --tags --refs --sort version:refname "$GH_REPO" |
grep -o 'refs/tags/.*' | cut -d/ -f3- |
sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags
}

list_all_versions() {
list_all_versions_sorted() {
# TODO: Adapt this. By default we simply list the tag names from GitHub releases.
# Change this function if tuist has other means of determining installable versions.
list_github_tags
list_github_tags_sorted
}

download_release() {
Expand Down

0 comments on commit bffa4c9

Please sign in to comment.