From 4a2a120b341793b1abaef5f12fbb4808277d8570 Mon Sep 17 00:00:00 2001 From: Yuta Katayama <8683947+yutkat@users.noreply.github.com> Date: Sun, 18 Sep 2022 06:51:03 +0000 Subject: [PATCH] fix: gh-r retrieves release data GH REST API (#373) Recent changes to GitHub HTML structure broke `gh-r` & `bpick` ices method of parsing project release assets. - `gh-r` utilizes official GitHub REST API to retrieve project releases data - add `local` scope to `releases_url` variable # closes #374 Co-authored-by: Tyler Wardhaugh --- zinit-install.zsh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/zinit-install.zsh b/zinit-install.zsh index 531f5299d..72d4c2d20 100644 --- a/zinit-install.zsh +++ b/zinit-install.zsh @@ -354,7 +354,13 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { ( if [[ $site = */releases ]] { - local url=$site/${ICE[ver]} + local tag_version=${ICE[ver]} + if [[ -z $tag_version ]]; then + tag_version="$( { .zinit-download-file-stdout $site/latest || .zinit-download-file-stdout $site/latest 1; } 2>/dev/null | \ + command grep -m1 -o 'href=./'$user'/'$plugin'/releases/tag/[^"]\+')" + tag_version=${tag_version##*/} + fi + local url=$site/expanded_assets/$tag_version .zinit-get-latest-gh-r-url-part "$user" "$plugin" "$url" || return $? @@ -1456,7 +1462,14 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { local user=$1 plugin=$2 urlpart=$3 if [[ -z $urlpart ]] { - local url=https://github.com/$user/$plugin/releases/$ICE[ver] + local tag_version=${ICE[ver]} + if [[ -z $tag_version ]]; then + local releases_url=https://github.com/$user/$plugin/releases/latest + tag_version="$( { .zinit-download-file-stdout $releases_url || .zinit-download-file-stdout $releases_url 1; } 2>/dev/null | \ + command grep -m1 -o 'href=./'$user'/'$plugin'/releases/tag/[^"]\+')" + tag_version=${tag_version##*/} + fi + local url=https://github.com/$user/$plugin/releases/expanded_assets/$tag_version } else { local url=https://$urlpart }