Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
szymmis committed Aug 16, 2023
1 parent e7ed50a commit a1af8f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions bin/latest-stable
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
fi

if grep -q "nightly"<<<"$1"; then
version="$(get_latest_nightly)"
if grep -q "nightly" <<<"$1"; then
version="$(get_latest_nightly)"
else
# curl of REPO/releases/latest is expected to be a 302 to another URL
# when no releases redirect_url="REPO/releases"
# when there are releases redirect_url="REPO/releases/tag/v<VERSION>"
redirect_url=$(curl "${curl_opts[@]}" "$GH_REPO/releases/latest" | sed -n -e "s|^location: *||p" | sed -n -e "s|\r||p")
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)"
else
version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/v\{0,1\}||')"
fi
# curl of REPO/releases/latest is expected to be a 302 to another URL
# when no releases redirect_url="REPO/releases"
# when there are releases redirect_url="REPO/releases/tag/v<VERSION>"
redirect_url=$(curl "${curl_opts[@]}" "$GH_REPO/releases/latest" | sed -n -e "s|^location: *||p" | sed -n -e "s|\r||p")
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)"
else
version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/v\{0,1\}||')"
fi
fi

printf "%s\n" "$version"
6 changes: 3 additions & 3 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ list_all_versions() {
list_github_tags
}

get_latest_nightly(){
git ls-remote --tags --refs "$GH_NIGHTLIES_REPO" |
get_latest_nightly() {
git ls-remote --tags --refs "$GH_NIGHTLIES_REPO" |
grep -o 'refs/tags/.*' | cut -d/ -f3- |
sort_versions | tail -n1 | xargs echo
sort_versions | tail -n1 | xargs echo
}

download_release() {
Expand Down

0 comments on commit a1af8f0

Please sign in to comment.