-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsparse.sh
More file actions
executable file
·49 lines (40 loc) · 1.38 KB
/
sparse.sh
File metadata and controls
executable file
·49 lines (40 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
set -euo pipefail
# --- CONFIGURATION ---
REPO_URL="https://github.com/HBClab/boost-beh.git"
BRANCH="main"
TEMP_DIR="/tmp/.temp_sparse_checkout"
TARGET_DATA_DIR="public/data"
TARGET_GROUP_DIR="public/group-plots"
# --- SPARSE CHECKOUT SETUP ---
echo "🔄 Creating sparse‐checkout in ${TEMP_DIR}"
rm -rf "${TEMP_DIR}"
mkdir -p "${TEMP_DIR}"
git init "${TEMP_DIR}"
git -C "${TEMP_DIR}" remote add origin "${REPO_URL}"
git -C "${TEMP_DIR}" config core.sparseCheckout true
# Tell Git which paths we want:
# • data/ → all of data
# • group/plots/ → just the plots subfolder
cat > "${TEMP_DIR}/.git/info/sparse-checkout" <<EOF
data/
group/plots/
data.json
EOF
# Fetch only that subset
echo "🔄 Pulling ${BRANCH} (depth=1)"
git -C "${TEMP_DIR}" pull --depth=1 origin "${BRANCH}"
# --- COPY OUT THE CHECKED‐OUT FOLDERS ---
# 1) Copy data → /app/public/data
echo "🔁 Copying data/ → ${TARGET_DATA_DIR}"
rm -rf "${TARGET_DATA_DIR}"
mkdir -p "${TARGET_DATA_DIR}"
cp -R "${TEMP_DIR}/data/." "${TARGET_DATA_DIR}/"
cp "${TEMP_DIR}/data.json" "${TARGET_DATA_DIR}/"
# 2) Copy plots into a flat 'group' folder → /app/public/group
echo "🔁 Copying group/plots/ → ${TARGET_GROUP_DIR}"
rm -rf "${TARGET_GROUP_DIR}"
mkdir -p "${TARGET_GROUP_DIR}"
cp -R "${TEMP_DIR}/group/plots/." "${TARGET_GROUP_DIR}/"
# --- CLEANUP ---
echo "✅ Cleaning up ${TEMP_DIR}"
rm -rf "${TEMP_DIR}"