Skip to content

Commit 7cc36aa

Browse files
Provide error response when failure occurs fetching Git tags (#1414)
* Provide error response when failure occurs fetching Git tags * bump version * Use alternative approach due to --fail-with-body only being available on newer curl releases --------- Co-authored-by: Álvaro Rausell Guiard <[email protected]>
1 parent 97fccab commit 7cc36aa

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/git/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "git",
3-
"version": "1.3.4",
3+
"version": "1.3.5",
44
"name": "Git (from source)",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/git",
66
"description": "Install an up-to-date version of Git, built from source as needed. Useful for when you want the latest and greatest features. Auto-detects latest stable version and installs needed dependencies.",

src/git/install.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,16 @@ fi
288288
# Partial version matching
289289
if [ "$(echo "${GIT_VERSION}" | grep -o '\.' | wc -l)" != "2" ]; then
290290
requested_version="${GIT_VERSION}"
291-
version_list="$(curl -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/git/git/tags" | grep -oP '"name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"' | sort -rV )"
291+
response_output_file=$(mktemp)
292+
trap 'rm "$response_output_file"' EXIT
293+
294+
http_code=$(curl --silent --output $response_output_file --write-out "%{http_code}" -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/git/git/tags")
295+
version_content=$(cat "$response_output_file")
296+
if [[ ${http_code} -lt 200 || ${http_code} -gt 299 ]] ; then
297+
echo "$version_content" >&2
298+
exit 1
299+
fi
300+
version_list="$(echo "$version_content" | grep -oP '"name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"' | sort -rV )"
292301
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "current" ]; then
293302
GIT_VERSION="$(echo "${version_list}" | head -n 1)"
294303
else

0 commit comments

Comments
 (0)