File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,14 +37,29 @@ command -v uv >/dev/null 2>&1 || {
3737}
3838UV_BIN=" $( command -v uv) "
3939
40- # 2. resolve the release tag (follow the /releases/latest redirect; no jq needed)
40+ # 2. resolve the release tag (GitHub API is used first; fallback keeps old behaviour).
4141if [ " $VERSION " = " latest" ]; then
42- url=$( curl -fsSLI -o /dev/null -w ' %{url_effective}' \
43- " https://github.com/$REPO /releases/latest" ) || {
42+ api_response=" $( mktemp) "
43+ if ! curl -fsSL \
44+ -H " Accept: application/vnd.github+json" \
45+ -H " User-Agent: git-auto-sync-installer" \
46+ " https://api.github.com/repos/$REPO /releases/latest" \
47+ -o " $api_response " ; then
48+ rm -f " $api_response "
4449 err " Couldn't reach GitHub to resolve the latest release."
4550 exit 1
46- }
47- TAG=" ${url##*/ } "
51+ fi
52+ TAG=" $( sed -n ' s/.*"tag_name"[[:space:]]*:[[:space:]]*"\\([^"]*\\)".*/\\1/p' " $api_response " | head -n 1) "
53+ rm -f " $api_response "
54+ if [ -z " $TAG " ] || [ " ${TAG# v} " = " $TAG " ]; then
55+ info " GitHub API did not return a release tag, falling back to web redirect resolution."
56+ url=" $( curl -fsSLI -o /dev/null -w ' %{url_effective}' \
57+ " https://github.com/$REPO /releases/latest" ) " || {
58+ err " Couldn't resolve the latest release."
59+ exit 1
60+ }
61+ TAG=" ${url##*/ } "
62+ fi
4863else
4964 TAG=" $VERSION "
5065fi
You can’t perform that action at this time.
0 commit comments