Last active
March 24, 2023 18:59
-
-
Save benjamin-asdf/37e0b30f93ecdb73e59c960297067662 to your computer and use it in GitHub Desktop.
Pull gitlibs like clj cli does it. Helps to pull in git deps in a sort of immutable spirit, if you have another ref, it pulls the other ref next to the existing one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "Usage: $0 <git-repo> <ref>" | |
exit 1 | |
fi | |
repo=$(echo $1 | sed -e 's/.*\///' -e 's/\.git$//') | |
mkdir -p .gitlibs/ | |
if [ ! -d .gitlibs/$repo ]; then | |
git clone --quiet --mirror $1 .gitlibs/$repo | |
fi | |
if [ ! -d .gitlibs/$repo/$2 ]; then | |
git --git-dir .gitlibs/$repo worktree add --force --detach .gitlibs/$repo/$2 $2 | |
fi | |
echo .gitlibs/$repo/$2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment