-
Notifications
You must be signed in to change notification settings - Fork 0
/
clone-all.sh
executable file
·88 lines (71 loc) · 2.26 KB
/
clone-all.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
cd "$(dirname "$0")"
shopt -s nullglob
nameRegex="/([^/ ]+)\.git$";
printf "Cloning repositories...\n\n";
while read line; do
if ! [ -z "$line" ]; then
if [[ $line =~ $nameRegex ]]; then
name=${BASH_REMATCH[1]};
else
printf "error: Malformed repository descriptor: '$line'. Skipping...\n\n";
continue;
fi
if [ -d "./Masters/$name" ]; then
printf "'$name' already exists, skipping...\n\n";
continue;
fi
remoteRegex="/([^/ ]+)/$name";
if [[ $line =~ $remoteRegex ]]; then
remoteRepo=${BASH_REMATCH[1]};
else
printf "error: Malformed repository descriptor: '$line'. Skipping.\n\n";
continue;
fi
printf "cloning '$line...\n";
cwd=$(pwd);
cd "./Masters";
git clone "$line";
if [ $? -ne 0 ]; then
printf "error: Failed to clone '$line'.\n\n";
continue;
fi
if ! [ -d "$name" ]; then
printf "error: No repository found for '$name' after cloning.\n\n";
continue;
fi
cd "./$name";
git remote rename origin "$remoteRepo";
cd "$cwd";
printf "done.\n\n";
fi
done < "./repo-list"
bash "./update-all.sh";
if [ -d "config" ]; then
printf "Building workspace and configuring repositories...\n\n";
while read line; do
if ! [ -z "$line" ]; then
if [[ $line =~ $nameRegex ]]; then
name=${BASH_REMATCH[1]};
else
printf "error: Malformed repository descriptor: '$line'. Skipping...\n\n";
continue;
fi
if ! [ -d "./Masters/$name" ]; then
printf "error: No repository found for '$name'.\n\n";
continue;
fi
cwd=$(pwd);
cd "./Masters/$name"
if [ -f "../../config/global" ]; then
source "../../config/global";
fi
if [ -f "../../config/$name" ]; then
source "../../config/$name";
fi
cd "$cwd";
fi
done < "./repo-list"
printf "Running post-configuration updates...\n\n";
bash "./update-all.sh";
fi