-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-update.sh
executable file
·55 lines (47 loc) · 1003 Bytes
/
git-update.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
#!/usr/bin/env bash
function update {
printf "Updating $1$2... "
output=$(git -C ${1}/ pull --rebase 2>&1)
handle_response
}
function clone {
printf "Cloning $1... "
output=$(git clone git@github.com:statisticsnorway/${1}.git 2>&1)
handle_response
}
function green {
printf '\e[32m%s\e[0m' "$1"
}
function red {
printf '\e[31m%s\e[0m' "$1"
}
function handle_response {
if [ $? -eq 0 ]
then
case "$output" in
*"up-to-date"*)
echo $(green "Already up-to-date")
;;
*"Cloning"*)
echo $(green "OK")
;;
*)
echo $(green "OK")
printf "$output\n\n"
;;
esac
else
echo $(red "ERROR")
printf "$output\n\n"
fi
}
update "." "jupyterhub-project"
while read -r repo
do
if [ -d ${repo} ];
then
update ${repo}
else
clone ${repo}
fi
done < git-repos.txt