-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_all_qor_repos.sh
executable file
·54 lines (42 loc) · 1.07 KB
/
update_all_qor_repos.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
tmp_dir=$(mktemp -d)
trap "rm -rf $tmp_dir" EXIT
function pull_chances {
local pkg=$(basename $2)
local pkg_path=$1/$2
if [ ! -d "$pkg_path/.git" ]; then
echo "$pkg not a git repo. skipped."
return 0
fi
cd $pkg_path
if [[ `git status -s --untracked-files=no` != "" ]]; then
echo "$pkg is not clean. please stash or commit your changes."
exit 1
fi
git checkout master >> /dev/null 2>&1 || {
echo "failed to update $pkg"
touch $tmp_dir/failed
exit 1
}
(git pull --rebase --quiet && echo -e "\033[31mUpdating $pkg...\033[0m") || {
echo -e "\033[31mfailed to update $pkg\033[0m"
touch $tmp_dir/failed
exit 1
}
}
function update_git_repo {
if [ -d "$1" ]; then
for pkg in $(ls $1); do
pull_chances $1 $pkg &
done
fi
}
update_git_repo $GOPATH/src/github.com/qor
update_git_repo $GOPATH/src/enterprise.getqor.com
wait
if [[ -f "$tmp_dir/failed" ]]; then
echo "failed"
exit 1
else
echo "done"
fi