-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·50 lines (47 loc) · 1.13 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
#!/bin/bash
#Notification for each repo
InitialNoti() {
GITFILE="/.git"
git --git-dir=$1$GITFILE fetch origin
RESLOG=$(git --git-dir=$1$GITFILE log HEAD..origin/master --oneline)
if [[ "${RESLOG}" != "" ]]; then
/usr/bin/osascript -e "display notification \"need to update\" with title \"$1\" subtitle \"$RESLOG\""
echo $RESLOG
else
echo ""
fi
}
Notification() {
GITFILE="/.git"
git --git-dir=$1$GITFILE fetch origin
RESLOG=$(git --git-dir=$1$GITFILE log HEAD..origin/master --oneline)
if [[ $RESLOG=$2 ]]; then
echo $RESLOG
else
if [[ "${RESLOG}" != "" ]]; then
/usr/bin/osascript -e "display notification \"need to update\" with title \"$1\" subtitle \"$RESLOG\""
echo $RESLOG
else
echo ""
fi
fi
}
while read folder; do
cd $folder
i=0
if [ -a "./.hashes" ]; then
while read -r repo && read -r hash <&3; do
RETVAL=$(Notification $repo $hash)
hashes[$i]=$RETVAL
i=$(($i+1))
done < "./.repos" 3<"./.hashes"
else
while read -r repo; do
RETVAL=$(InitialNoti $repo)
hashes[$i]=$RETVAL
i=$(($i+1))
done < "./.repos"
fi
printf "%s\n" "${hashes[@]}" > ".hashes"
unset hashes
done < "./.folders"