Skip to content

Commit 7f6e473

Browse files
committed
fix(tools.func): handle GitHub 300 Multiple Choices in tarball mode
When a GitHub repository has both a branch and a tag with the same name (e.g. Pangolin's '1.12.3'), the API's tarball_url and zipball_url return HTTP 300 Multiple Choices instead of a redirect. curl saves the JSON response body as the file, causing 'gzip: stdin: not in gzip format' when tar tries to extract. This fix uses the explicit refs/tags/ URL format instead: https://github.com/$repo/archive/refs/tags/$tag.tar.gz This URL always returns a proper 302 redirect to the tarball, avoiding the ambiguity between branch and tag names. Fixes: #9694
1 parent fd8a305 commit 7f6e473

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

misc/tools.func

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,12 +1728,13 @@ function fetch_and_deploy_gh_release() {
17281728

17291729
### Tarball Mode ###
17301730
if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then
1731-
url=$(echo "$json" | jq -r '.tarball_url // empty')
1732-
[[ -z "$url" ]] && url="https://github.com/$repo/archive/refs/tags/v$version.tar.gz"
1731+
# GitHub API's tarball_url/zipball_url can return HTTP 300 Multiple Choices
1732+
# when a branch and tag share the same name. Use explicit refs/tags/ URL instead.
1733+
local direct_tarball_url="https://github.com/$repo/archive/refs/tags/$tag_name.tar.gz"
17331734
filename="${app_lc}-${version}.tar.gz"
17341735

1735-
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$url" || {
1736-
msg_error "Download failed: $url"
1736+
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$direct_tarball_url" || {
1737+
msg_error "Download failed: $direct_tarball_url"
17371738
rm -rf "$tmpdir"
17381739
return 1
17391740
}

0 commit comments

Comments
 (0)