-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclone_baselines.sh
More file actions
executable file
·117 lines (106 loc) · 2.92 KB
/
clone_baselines.sh
File metadata and controls
executable file
·117 lines (106 loc) · 2.92 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
# Clone or update agent baseline upstreams into fixed paths under this repository.
#
# Mappings (MetaGPT: FoundationAgents per THIRD_PARTY_NOTICES.md):
# Game_Tars/OmniParser <- https://github.com/microsoft/OmniParser.git
# baselines/DeepCode <- https://github.com/HKUDS/DeepCode.git
# baselines/MetaGPT <- https://github.com/FoundationAgents/MetaGPT.git
# baselines/OpenManus <- https://github.com/FoundationAgents/OpenManus.git
#
# If a target path exists but is not a git working tree (no ".git"), the script exits
# with an error and does not delete or overwrite files.
#
# Usage:
# ./clone_baselines.sh
# ./clone_baselines.sh --shallow
# SHALLOW=1 ./clone_baselines.sh
# ./clone_baselines.sh --dry-run
# DRY_RUN=1 ./clone_baselines.sh
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SHALLOW="${SHALLOW:-0}"
DRY_RUN="${DRY_RUN:-0}"
while [[ $# -gt 0 ]]; do
case "$1" in
--shallow)
SHALLOW=1
shift
;;
--dry-run)
DRY_RUN=1
shift
;;
-h|--help)
sed -n '1,25p' "$0"
exit 0
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done
# shellcheck disable=SC2034
declare -a _BASELINE_URLS=(
"https://github.com/microsoft/OmniParser.git"
"https://github.com/HKUDS/DeepCode.git"
"https://github.com/FoundationAgents/MetaGPT.git"
"https://github.com/FoundationAgents/OpenManus.git"
)
declare -a _BASELINE_RELPATHS=(
"Game_Tars/OmniParser"
"baselines/DeepCode"
"baselines/MetaGPT"
"baselines/OpenManus"
)
failures=0
for i in "${!_BASELINE_URLS[@]}"; do
url="${_BASELINE_URLS[$i]}"
rel="${_BASELINE_RELPATHS[$i]}"
target="${ROOT}/${rel}"
if [[ -e "$target" && ! -e "${target}/.git" ]]; then
echo "Refusing to clone: path exists but is not a git repo: ${target}" >&2
echo "Move or remove it, then re-run." >&2
exit 1
fi
if [[ -d "${target}/.git" ]]; then
if [[ "$DRY_RUN" == "1" ]]; then
echo "[pull] ${target}"
continue
fi
echo "[update] ${rel}"
if ! git -C "${target}" pull --ff-only; then
echo "[warn] pull failed: ${target}" >&2
failures=$((failures + 1))
fi
continue
fi
if [[ "$DRY_RUN" == "1" ]]; then
if [[ "$SHALLOW" == "1" ]]; then
echo "[clone shallow] ${url} -> ${target}"
else
echo "[clone] ${url} -> ${target}"
fi
continue
fi
echo "[clone] ${rel}"
mkdir -p "$(dirname "${target}")"
if [[ "$SHALLOW" == "1" ]]; then
if ! git clone --depth 1 "${url}" "${target}"; then
echo "[warn] clone failed: ${url}" >&2
failures=$((failures + 1))
fi
else
if ! git clone "${url}" "${target}"; then
echo "[warn] clone failed: ${url}" >&2
failures=$((failures + 1))
fi
fi
done
if [[ "$failures" -gt 0 ]]; then
echo "Finished with ${failures} error(s)." >&2
exit 1
fi
if [[ "$DRY_RUN" != "1" ]]; then
echo "Baseline repos are under: ${ROOT}"
fi