3.1 KiB
3.1 KiB
You can use the following script to do a swallow and sparse download/clone of all the dependent files, including textures, drawing assets, etc.
Just copy and paste the entire script into Git Bash. Will take a couple minutes to download.
# ===== Timer =====
SECONDS=0
# ===== Configuration =====
URL="https://hub.openingdesign.com/OpeningDesign/Cool_Car_Guys.git"
SPARSE_PATH="Open/Models/Bonsai"
COMMIT="ae461671e684f51816e10fa1a42f80dbcae2096c"
SKIP_FOLDERS=("Open/Models/Bonsai/OD_Textures")
# ===== Helper Function =====
format_time() {
local sec=$1
printf "%dm %ds" $((sec / 60)) $((sec % 60))
}
# ===== Extract Repo Name =====
REPO_NAME=$(basename -s .git "$URL")
echo "=== Starting clone process ==="
echo "Cloning into folder: $REPO_NAME"
# ===== Clone Repo (shallow, no checkout, live progress) =====
STEP_START=$SECONDS
echo "=== Cloning repository (shallow, no checkout) ==="
git clone --depth=1 --filter=blob:none --no-checkout "$URL" "$REPO_NAME"
cd "$REPO_NAME"
STEP_TIME=$((SECONDS - STEP_START))
echo "Clone completed in $(format_time $STEP_TIME)"
# ===== Initialize Sparse Checkout =====
STEP_START=$SECONDS
echo "=== Initializing sparse-checkout ==="
git sparse-checkout init --cone
SPARSE_SET=("$SPARSE_PATH")
for skip in "${SKIP_FOLDERS[@]}"; do
skip=${skip//\\//}
SPARSE_SET+=("!$skip")
done
echo "=== Setting sparse-checkout paths: ${SPARSE_SET[*]} ==="
git sparse-checkout set "${SPARSE_SET[@]}"
STEP_TIME=$((SECONDS - STEP_START))
echo "Sparse-checkout setup completed in $(format_time $STEP_TIME)"
# ===== Checkout Specific Commit (with spinner) =====
if [ -n "$COMMIT" ]; then
STEP_START=$SECONDS
echo "=== Checking out commit $COMMIT ==="
git checkout "$COMMIT" &
CHECKOUT_PID=$!
spin='-\|/'
i=0
while kill -0 $CHECKOUT_PID 2>/dev/null; do
i=$(( (i+1) %4 ))
printf "\rChecking out... ${spin:$i:1}"
sleep 0.2
done
wait $CHECKOUT_PID
echo -e "\rCheckout complete! "
STEP_TIME=$((SECONDS - STEP_START))
echo "Checkout completed in $(format_time $STEP_TIME)"
fi
# ===== Initialize Submodules =====
STEP_START=$SECONDS
echo "=== Initializing submodules ==="
git submodule init
for skip in "${SKIP_FOLDERS[@]}"; do
skip=${skip//\\//}
sub_name=$(git config -f .gitmodules --get-regexp path | grep "$skip" | awk '{print $1}' | sed 's/submodule\.//;s/\.path//')
if [ -n "$sub_name" ]; then
echo "Temporarily disabling submodule: $sub_name ($skip)"
git config submodule."$sub_name".update none
git config submodule."$sub_name".active false
fi
done
git submodule update --init --recursive --depth=1 --progress
STEP_TIME=$((SECONDS - STEP_START))
echo "Submodule update completed in $(format_time $STEP_TIME)"
# ===== Completion Summary =====
TOTAL_TIME=$SECONDS
echo ""
echo "=== Clone and setup completed in $(format_time $TOTAL_TIME) ==="
echo ""
echo "Note: Skipped submodules were not downloaded."
echo " To download one later, run inside this repo:"
for skip in "${SKIP_FOLDERS[@]}"; do
echo " git submodule update --init --recursive '$skip'"
done
echo ""
read -p "Press Enter to close this window..."