-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·77 lines (62 loc) · 1.29 KB
/
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
#
# Copyright (c) Sebastian Kucharczyk <kuchen@kekse.biz>
#
#
real="$(realpath "$0")"
dir="$(dirname "$real")"
#
cd "$dir"
#
_GIT_DATE_FORMAT='%s'
_GIT_UPDATE_MESSAGE='' #Global github://kekse1/ update'
if [[ $# -eq 0 ]]; then
echo -e " >> Global update without add/commit/push! :-)"
else
_GIT_UPDATE_DATE="`date +\"${_GIT_DATE_FORMAT}\"`"
_GIT_UPDATE_MESSAGE="$*"
echo " >> Global update with commit message (${_GIT_UPDATE_DATE}):"
echo " '$*'"
_GIT_UPDATE_MESSAGE="[${_GIT_UPDATE_DATE}] ${_GIT_UPDATE_MESSAGE}"
fi
echo -e "\n\n"
count=0
errors=0
for i in *; do
[[ -d $i ]] || continue
[[ -d $i/.git ]] || continue
let count=$count+1
cd $i/
if [[ $? -eq 0 ]]; then
echo -e "\n\n >> '$i'\n\n"
else
cd ../
let errors=$errors+1
echo -e "\n\nError #${errors}! :-(\n\n"
continue
fi
git pull
if [[ $? -ne 0 ]]; then
cd ../
let errors=$errors+1
echo -e "\n\nError #${errors}! :-(\n\n"
continue
fi
if [[ $# -eq 0 ]]; then
cd ../
continue
fi
git add --all
git commit -m "$_txt"
git push
if [[ $? -ne 0 ]]; then
let errors=$errors+1
echo -e "\n\nError #${errors}! :-/"
fi
echo
echo
cd ../
done
echo; echo; echo;
echo -e " >> Totally $count repositories updated! :-)"
[[ $errors -gt 0 ]] && echo -e " >> But there were $errors errors!" >&2