Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/git/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
9 changes: 7 additions & 2 deletions src/git/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ elif [ "${ADJUSTED_ID}" = "alpine" ]; then
${INSTALL_CMD} add --no-cache --update curl grep make zlib-dev

# ref. <https://github.com/alpinelinux/aports/blob/32ac93ffb642031b88ba8639fbb3abb324169dea/main/git/APKBUILD#L62>
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
Expand Down Expand Up @@ -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!"
4 changes: 4 additions & 0 deletions test/git/install_git_from_src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/git/install_git_from_src_alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/git/install_git_from_src_bookworm.sh
16 changes: 0 additions & 16 deletions test/git/install_git_from_src_centos-7.sh

This file was deleted.

4 changes: 4 additions & 0 deletions test/git/install_git_from_src_noble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/git/install_git_from_src_trixie.sh
15 changes: 12 additions & 3 deletions test/git/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"install_git_from_src": {
"image": "ubuntu:noble",
"image": "ubuntu:resolute",
"features": {
"git": {
"version": "latest",
Expand Down Expand Up @@ -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",
Expand Down
19 changes: 19 additions & 0 deletions test/git/utils.sh
Original file line number Diff line number Diff line change
@@ -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" ]
}
Loading