From 809a7f1f76a2d6d25bd5c024a4ea3a87f8c6ea8f Mon Sep 17 00:00:00 2001 From: Eimhin Laverty Date: Fri, 18 Jul 2025 09:39:56 +0100 Subject: [PATCH 1/3] Provide error response when failure occurs fetching Git tags --- src/git/install.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/git/install.sh b/src/git/install.sh index 4124fc80c..fb1db2b6d 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -288,7 +288,13 @@ fi # Partial version matching if [ "$(echo "${GIT_VERSION}" | grep -o '\.' | wc -l)" != "2" ]; then requested_version="${GIT_VERSION}" - 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 )" + version_response="$(curl --fail-with-body -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/git/git/tags")" + if [ $? != 0 ]; then + echo "Failed to fetch git versions from GitHub API:" >&2 + echo "$version_response" >&2 + exit 1 + fi + version_list="$(echo "$version_response" | grep -oP '"name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"' | sort -rV )" if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "current" ]; then GIT_VERSION="$(echo "${version_list}" | head -n 1)" else From ca40f446ce9b3437a01a1e18e234f7565797a61a Mon Sep 17 00:00:00 2001 From: Eimhin Laverty Date: Sat, 19 Jul 2025 22:51:25 +0100 Subject: [PATCH 2/3] bump version --- src/git/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/git/devcontainer-feature.json b/src/git/devcontainer-feature.json index 7531ad2ab..5aa83a8b1 100644 --- a/src/git/devcontainer-feature.json +++ b/src/git/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "git", - "version": "1.3.4", + "version": "1.3.5", "name": "Git (from source)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/git", "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.", From b3b7ba91f094727e36b88517213b8e1b7594affb Mon Sep 17 00:00:00 2001 From: Eimhin Laverty Date: Mon, 21 Jul 2025 09:37:51 +0100 Subject: [PATCH 3/3] Use alternative approach due to --fail-with-body only being available on newer curl releases --- src/git/install.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/git/install.sh b/src/git/install.sh index fb1db2b6d..7ee301b7e 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -288,13 +288,16 @@ fi # Partial version matching if [ "$(echo "${GIT_VERSION}" | grep -o '\.' | wc -l)" != "2" ]; then requested_version="${GIT_VERSION}" - version_response="$(curl --fail-with-body -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/git/git/tags")" - if [ $? != 0 ]; then - echo "Failed to fetch git versions from GitHub API:" >&2 - echo "$version_response" >&2 + response_output_file=$(mktemp) + trap 'rm "$response_output_file"' EXIT + + 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") + version_content=$(cat "$response_output_file") + if [[ ${http_code} -lt 200 || ${http_code} -gt 299 ]] ; then + echo "$version_content" >&2 exit 1 fi - version_list="$(echo "$version_response" | grep -oP '"name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"' | sort -rV )" + version_list="$(echo "$version_content" | grep -oP '"name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"' | sort -rV )" if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "current" ]; then GIT_VERSION="$(echo "${version_list}" | head -n 1)" else