Skip to content
Draft
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
9 changes: 7 additions & 2 deletions src/git/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "git",
"version": "1.3.2",
"version": "1.3.3",
"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 All @@ -19,7 +19,12 @@
"type": "boolean",
"default": true,
"description": "Install from PPA if available (only supported for Ubuntu distributions)"
}
},
"installSubtree": {
"type": "boolean",
"default": true,
"description": "Install git/contrib/subtree"
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
Expand Down
68 changes: 67 additions & 1 deletion src/git/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

GIT_VERSION=${VERSION} # 'system' checks the base image first, else installs 'latest'
USE_PPA_IF_AVAILABLE=${PPA}
INSTALL_SUBTREE="${INSTALLSUBTREE:-"true"}"

GIT_CORE_PPA_ARCHIVE_GPG_KEY=E1DD270288B4E6030699E45FA1715D88E1DF1F24

Expand Down Expand Up @@ -208,7 +209,32 @@ export DEBIAN_FRONTEND=noninteractive
if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then
if type git > /dev/null 2>&1; then
echo "Detected existing system install: $(git version)"
# Clean up
if [[ $INSTALL_SUBTREE = "true" ]]; then

if ! type make > /dev/null 2>&1; then
check_packages make
fi
if ! type asciidoc > /dev/null 2>&1; then
check_packages asciidoc
fi
if ! type xmlto > /dev/null 2>&1; then
check_packages xmlto
fi
if ! type tar > /dev/null 2>&1; then
check_packages tar
fi
if ! type curl > /dev/null 2>&1; then
check_packages curl
fi
cd /tmp/
GIT_VERSION=$(git --version | awk '{print $3}')
curl -sL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz | tar -xzC /tmp 2>&1
cd /tmp/git-${GIT_VERSION}
cd contrib/subtree
make && make install && make install-doc && cp git-subtree ../.. 2>&1
cd ../../
rm -rf /tmp/git-${GIT_VERSION}
fi
clean_up
exit 0
fi
Expand All @@ -224,6 +250,41 @@ if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then
check_packages ca-certificates
fi
check_packages git
if [[ $INSTALL_SUBTREE = "true" ]]; then
if ! type make > /dev/null 2>&1; then
check_packages make
fi
if ! type asciidoc > /dev/null 2>&1; then
check_packages asciidoc
fi
if ! type xmlto > /dev/null 2>&1; then
check_packages xmlto
fi
if ! type tar > /dev/null 2>&1; then
check_packages tar
fi
if ! type curl > /dev/null 2>&1; then
check_packages curl
fi
if ! type cmp > /dev/null 2>&1; then
check_packages diffutils
fi
cd /tmp/
GIT_VERSION=$(git --version | awk '{print $3}')
curl -sL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz | tar -xzC /tmp 2>&1
cd /tmp/git-${GIT_VERSION}
cd contrib/subtree
make && make install && make install-doc && cp git-subtree ../.. 2>&1
cd ../../
#For some base images such as alma, rocky, fedora git subtree feature doesn’t work
# even after successful subtree installation. This happens particularly when the git
# version provided by default is an old one. Adding the installation path specifically
# for them.
if [ -f "/usr/local/libexec/git-core/git-subtree" ]; then
echo 'export PATH=$PATH:/usr/local/libexec/git-core' >> ~/.bashrc
fi
rm -rf /tmp/git-${GIT_VERSION}
fi
# Clean up
clean_up
exit 0
Expand Down Expand Up @@ -309,6 +370,11 @@ if [ "${ADJUSTED_ID}" = "alpine" ]; then
git_options+=("NO_GETTEXT=YesPlease")
fi
make -s "${git_options[@]}" all && make -s "${git_options[@]}" install 2>&1
if [[ $INSTALL_SUBTREE = "true" ]]; then
cd contrib/subtree/
make && make install && make install-doc && cp git-subtree ../.. 2>&1
cd ../../
fi
rm -rf /tmp/git-${GIT_VERSION}
clean_up
echo "Done!"
18 changes: 0 additions & 18 deletions test/git/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,6 @@
}
}
},
"install_git_from_src_mariner": {
"image": "mcr.microsoft.com/cbl-mariner/base/core:2.0",
"features": {
"git": {
"version": "latest",
"ppa": "false"
}
}
},
"install_git_from_system_alpine": {
"image": "mcr.microsoft.com/devcontainers/base:alpine",
"features": {
Expand Down Expand Up @@ -187,14 +178,5 @@
"ppa": "true"
}
}
},
"install_git_from_system_mariner": {
"image": "mcr.microsoft.com/cbl-mariner/base/core:2.0",
"features": {
"git": {
"version": "system",
"ppa": "true"
}
}
}
}
Loading