Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit401f8b4

Browse files
authored
provide useful debug info when retrieving a version from GitHub fails (#15956)
Closes#15851This fails the installation when the version cannot be retrieved, andprints useful debug info.`install.sh` could use with more error-handling in general, but this atleast ameliorates the linked issue.Signed-off-by: Danny Kopping <danny@coder.com>
1 parent5e88289 commit401f8b4

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

‎install.sh‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,19 @@ EOF
9292
}
9393

9494
echo_latest_stable_version() {
95+
url="https://github.com/coder/coder/releases/latest"
9596
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860
96-
version="$(curl -fsSLI -o /dev/null -w"%{url_effective}" https://github.com/coder/coder/releases/latest)"
97+
response=$(curl -sSLI -o /dev/null -w"\n%{http_code} %{url_effective}"${url})
98+
status_code=$(echo"$response"| tail -n1| cut -d'' -f1)
99+
version=$(echo"$response"| tail -n1| cut -d'' -f2-)
100+
body=$(echo"$response"| sed'$d')
101+
102+
if ["$status_code"!="200" ];then
103+
echoerr"GitHub API returned status code:${status_code}"
104+
echoerr"URL:${url}"
105+
exit 1
106+
fi
107+
97108
version="${version#https://github.com/coder/coder/releases/tag/v}"
98109
echo"${version}"
99110
}
@@ -103,7 +114,19 @@ echo_latest_mainline_version() {
103114
# and take the first result. Note that we're sorting by space-
104115
# separated numbers and without utilizing the sort -V flag for the
105116
# best compatibility.
106-
curl -fsSL https://api.github.com/repos/coder/coder/releases|
117+
url="https://api.github.com/repos/coder/coder/releases"
118+
response=$(curl -sSL -w"\n%{http_code}"${url})
119+
status_code=$(echo"$response"| tail -n1)
120+
body=$(echo"$response"| sed'$d')
121+
122+
if ["$status_code"!="200" ];then
123+
echoerr"GitHub API returned status code:${status_code}"
124+
echoerr"URL:${url}"
125+
echoerr"Response body:${body}"
126+
exit 1
127+
fi
128+
129+
echo"$body"|
107130
awk -F'"''/"tag_name"/ {print $4}'|
108131
tr -d v|
109132
tr.''|
@@ -405,8 +428,10 @@ main() {
405428
STABLE_VERSION=$(echo_latest_stable_version)
406429
if ["${MAINLINE}"= 1 ];then
407430
VERSION=$(echo_latest_mainline_version)
431+
echoh"Resolved mainline version: v${VERSION}"
408432
elif ["${STABLE}"= 1 ];then
409433
VERSION=${STABLE_VERSION}
434+
echoh"Resolved stable version: v${VERSION}"
410435
fi
411436

412437
distro_name

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp