aboutsummaryrefslogtreecommitdiff
path: root/src/git-lfs/install.sh
diff options
context:
space:
mode:
authorJosh Spicer <joshspicer@github.com>2023-04-04 16:47:04 +0300
committerGitHub <noreply@github.com>2023-04-04 16:47:04 +0300
commit2952d87f1db5681330db025e17ab4357a1bdc275 (patch)
tree5995fa11175a7ef1b49c497d400e4d6aa39034d4 /src/git-lfs/install.sh
parent1118b992d970b53d92b3379a5b05de7738f3dc8b (diff)
add a postCreateCommand to `git-lfs` Feature (#511)feature_git-lfs_1.1.0
* add a postCreateCommand to git-lfs Feature * debug passing locally but not in CI * update scenario * add GIT_LFS_SKIP_SMUDGE=1 to prevent fetching lfs arifacts in github actions * arguments should be booleans * move example repo to devcontainers org * place script literally anywhere other than /tmp
Diffstat (limited to 'src/git-lfs/install.sh')
-rwxr-xr-xsrc/git-lfs/install.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/git-lfs/install.sh b/src/git-lfs/install.sh
index d6f914f..3931099 100755
--- a/src/git-lfs/install.sh
+++ b/src/git-lfs/install.sh
@@ -8,6 +8,7 @@
# Maintainer: The VS Code and Codespaces Teams
GIT_LFS_VERSION=${VERSION:-"latest"}
+AUTO_PULL=${AUTOPULL:="true"}
GIT_LFS_ARCHIVE_GPG_KEY_URI="https://packagecloud.io/github/git-lfs/gpgkey"
GIT_LFS_ARCHIVE_ARCHITECTURES="amd64 arm64"
@@ -185,6 +186,37 @@ if [ "${use_github}" = "true" ]; then
install_using_github
fi
+# --- Generate a 'pull-git-lfs-artifacts.sh' script to be executed by the 'postCreateCommand' lifecycle hook
+PULL_GIT_LFS_SCRIPT_PATH="/usr/local/share/pull-git-lfs-artifacts.sh"
+
+tee "$PULL_GIT_LFS_SCRIPT_PATH" > /dev/null \
+<< EOF
+#!/bin/sh
+set -e
+AUTO_PULL=${AUTO_PULL}
+EOF
+
+tee -a "$PULL_GIT_LFS_SCRIPT_PATH" > /dev/null \
+<< 'EOF'
+
+echo "Fetching git lfs artifacts..."
+
+if [ "${AUTO_PULL}" != "true" ]; then
+ echo "(!) Skipping 'git lfs pull' because 'autoPull' is not set to 'true'"
+ exit 0
+fi
+
+# Check if repo is a git lfs repo.
+if ! git lfs ls-files > /dev/null 2>&1; then
+ echo "(!) Skipping automatic 'git lfs pull' because no git lfs files were detected"
+ exit 0
+fi
+
+git lfs pull
+EOF
+
+chmod 755 "$PULL_GIT_LFS_SCRIPT_PATH"
+
# Clean up
rm -rf /var/lib/apt/lists/*