-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull.sh
executable file
·65 lines (53 loc) · 1.64 KB
/
pull.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
source options.sh
CLEAR_GIT_FILES=$([ "$1" = "--clear-git-files" ] && echo true || echo false)
clone_or_pull() {
local target_dir="$1"
local repo="$2"
local branch="$3"
local working_dir="$PWD"
if [ -d "$target_dir" ]; then
echo "Pulling latest $repo"
cd "$target_dir" || exit 1
git fetch --all
git checkout "$branch"
git merge --ff-only
cd "$working_dir"
else
echo Cloning "$repo"
git clone --filter=blob:none -b "$branch" "[email protected]:nesfit/$repo.git" "$target_dir"
if $CLEAR_GIT_FILES; then
cd "$target_dir"
rm -rf ".git"
cd "$working_dir"
fi
fi
}
check_git_lfs() {
# Check if Git LFS is installed
if ! command -v git-lfs >/dev/null 2>&1; then
return 1
fi
# Check if Git LFS is initialized
if ! git lfs env >/dev/null 2>&1; then
echo "Git LFS is installed but not initialized. Initializing..."
git lfs install
if [ $? -eq 0 ]; then
echo "Git LFS initialized successfully."
return 0
else
echo "Failed to initialize Git LFS."
return 1
fi
fi
return 0
}
clone_or_pull "$INFRA_DIR" "domainradar-infra" "$INFRA_BRANCH"
clone_or_pull "$COLEXT_DIR" "domainradar-colext" "$COLEXT_BRANCH"
clone_or_pull "$LOADER_DIR" "domainradar-input" "$LOADER_BRANCH"
clone_or_pull "$WEBUI_DIR" "domainradar-ui" "$WEBUI_BRANCH"
if check_git_lfs; then
clone_or_pull "$CLF_DIR" "domainradar-clf" "$CLF_BRANCH"
else
echo "Git LFS is not installed, cannot pull the classifiers."
fi