diff --git a/src/git/devcontainer-feature.json b/src/git/devcontainer-feature.json index 93ea7b061..46b49b27f 100644 --- a/src/git/devcontainer-feature.json +++ b/src/git/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "git", - "version": "1.3.6", + "version": "1.3.7", "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.", diff --git a/src/git/install.sh b/src/git/install.sh index ed20a8ce5..d214e3e32 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -263,10 +263,10 @@ elif [ "${ADJUSTED_ID}" = "alpine" ]; then ${INSTALL_CMD} add --no-cache --update curl grep make zlib-dev # ref. - check_packages asciidoc curl-dev expat-dev g++ gcc openssl-dev pcre2-dev perl-dev perl-error python3-dev tcl tk xmlto + check_packages asciidoc curl-dev expat-dev g++ gcc linux-headers openssl-dev pcre2-dev perl-dev perl-error python3-dev tcl tk xmlto elif [ "${ADJUSTED_ID}" = "rhel" ]; then - check_packages gcc libcurl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel cmake pcre2-devel tar gzip ca-certificates + check_packages gcc make libcurl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel cmake pcre2-devel tar gzip ca-certificates if ! type curl > /dev/null 2>&1; then check_packages curl fi @@ -325,6 +325,11 @@ if [ "${ADJUSTED_ID}" = "alpine" ]; then git_options+=("NO_GETTEXT=YesPlease") fi make -s "${git_options[@]}" all && make -s "${git_options[@]}" install 2>&1 +build_result=$? rm -rf /tmp/git-${GIT_VERSION} clean_up +if [ "${build_result}" -ne 0 ]; then + echo "(!) Failed to build and install git ${GIT_VERSION}." >&2 + exit 1 +fi echo "Done!" diff --git a/test/git/install_git_from_src.sh b/test/git/install_git_from_src.sh index d0ebaa282..4888c25fb 100644 --- a/test/git/install_git_from_src.sh +++ b/test/git/install_git_from_src.sh @@ -5,8 +5,12 @@ set -e # Optional: Import test library source dev-container-features-test-lib +# Import shared helper functions +source "$(dirname "$0")/utils.sh" + # Definition specific tests check "version" git --version +check "version-is-latest" check_git_is_latest_version check "gettext" dpkg-query -l gettext cd /tmp && git clone https://github.com/devcontainers/feature-starter.git diff --git a/test/git/install_git_from_src_alpine.sh b/test/git/install_git_from_src_alpine.sh index 2a26beec5..a9a9d7d9c 100644 --- a/test/git/install_git_from_src_alpine.sh +++ b/test/git/install_git_from_src_alpine.sh @@ -5,8 +5,12 @@ set -e # Optional: Import test library source dev-container-features-test-lib +# Import shared helper functions +source "$(dirname "$0")/utils.sh" + # Definition specific tests check "version" git --version +check "version-is-latest" check_git_is_latest_version cd /tmp && git clone https://github.com/devcontainers/feature-starter.git cd feature-starter diff --git a/test/git/install_git_from_src_bookworm.sh b/test/git/install_git_from_src_bookworm.sh new file mode 120000 index 000000000..aa0c8ade6 --- /dev/null +++ b/test/git/install_git_from_src_bookworm.sh @@ -0,0 +1 @@ +install_git_from_src.sh \ No newline at end of file diff --git a/test/git/install_git_from_src_centos-7.sh b/test/git/install_git_from_src_centos-7.sh deleted file mode 100644 index 84800b543..000000000 --- a/test/git/install_git_from_src_centos-7.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -e - -# Optional: Import test library -source dev-container-features-test-lib - -# Definition specific tests -check "version" git --version - -cd /tmp && git clone https://github.com/devcontainers/feature-starter.git -cd feature-starter -check "perl" bash -c "git -c grep.patternType=perl grep -q 'a.+b'" - -# Report result -reportResults diff --git a/test/git/install_git_from_src_noble.sh b/test/git/install_git_from_src_noble.sh index 337226fdc..dae12450b 100644 --- a/test/git/install_git_from_src_noble.sh +++ b/test/git/install_git_from_src_noble.sh @@ -5,8 +5,12 @@ set -e # Optional: Import test library source dev-container-features-test-lib +# Import shared helper functions +source "$(dirname "$0")/utils.sh" + # Definition specific tests check "version" git --version +check "latest version" check_git_is_latest_version check "gettext" dpkg-query -l gettext cd /tmp && git clone https://github.com/devcontainers/feature-starter.git diff --git a/test/git/install_git_from_src_trixie.sh b/test/git/install_git_from_src_trixie.sh new file mode 120000 index 000000000..aa0c8ade6 --- /dev/null +++ b/test/git/install_git_from_src_trixie.sh @@ -0,0 +1 @@ +install_git_from_src.sh \ No newline at end of file diff --git a/test/git/scenarios.json b/test/git/scenarios.json index 7feff6564..ce110d3c5 100644 --- a/test/git/scenarios.json +++ b/test/git/scenarios.json @@ -1,6 +1,6 @@ { "install_git_from_src": { - "image": "ubuntu:noble", + "image": "ubuntu:resolute", "features": { "git": { "version": "latest", @@ -53,8 +53,17 @@ } } }, - "install_git_from_src_centos-7": { - "image": "centos:centos7", + "install_git_from_src_bookworm": { + "image": "debian:bookworm", + "features": { + "git": { + "version": "latest", + "ppa": "false" + } + } + }, + "install_git_from_src_trixie": { + "image": "debian:trixie", "features": { "git": { "version": "latest", diff --git a/test/git/utils.sh b/test/git/utils.sh new file mode 100644 index 000000000..6b5b03f93 --- /dev/null +++ b/test/git/utils.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Shared helper functions for git "install from source" test scenarios. + +# Resolves the latest stable git version from GitHub +get_latest_git_version() { + 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]+(?=")' \ + | sort -rV \ + | head -n 1 +} + +# Verifies the installed git version matches the latest stable version on GitHub +check_git_is_latest_version() { + local latest_version installed_version + latest_version="$(get_latest_git_version)" + installed_version="$(git --version | awk '{print $3}')" + [ -n "$latest_version" ] && [ "$installed_version" = "$latest_version" ] +}