Skip to content

Commit

Permalink
fix: Support Unison versions with arch in URL (≥ 0.5.28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Arnett committed Dec 26, 2024
1 parent cc3c448 commit a67cf42
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,29 @@ platform() {
esac
}

arch() {
local arch_check=${ASDF_UNISON_OVERWRITE_ARCH:-"$(uname -m)"}
case "${arch_check}" in
x86_64 | amd64) echo "x64" ;;
aarch64 | arm64) echo "arm64" ;;
*) fail "Arch '${arch_check}' not supported!" ;;
esac
}

download_release() {
local version filename url
local version filename url major minor patch
version="$1"
filename="$2"

url="$GH_REPO/releases/download/release/${version}/ucm-$(platform).tar.gz"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
patch=$(echo "$version" | cut -d. -f3)

if [ $(echo "$version" | head -c 1) = "M" ] || [ $major -eq 0 -a $minor -le 5 -a $patch -le 27 ]; then
url="$GH_REPO/releases/download/release/${version}/ucm-$(platform).tar.gz"
else
url="$GH_REPO/releases/download/release/${version}/ucm-$(platform)-$(arch).tar.gz"
fi

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
Expand Down

0 comments on commit a67cf42

Please sign in to comment.