-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitStatus.sh
More file actions
executable file
·71 lines (57 loc) · 1.16 KB
/
gitStatus.sh
File metadata and controls
executable file
·71 lines (57 loc) · 1.16 KB
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
#!/bin/sh
# Maintained at: git@github.com:dareni/shellscripts.git
#Print the status of all git repo subdirectories.
defaultStatus() {
git remote update
LOCAL=$(git rev-parse @{0})
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
STATUS="Up-to-date"
elif [ "$LOCAL" = "$BASE" ]; then
STATUS="Need-to-pull"
elif [ "$REMOTE" = "$BASE" ]; then
STATUS="Need-to-push"
else
STATUS="Diverged"
fi
DETAIL=`git status -z`
if [ -n "$DETAIL" -o "$STATUS" != "Up-to-date" ]; then
echo " ::: $STATUS"
git status -s
echo "\n\n"
fi
}
stashStatus() {
git stash list
echo "\n"
}
OLDPWD=`pwd`
CMD=""
if [ -z "$1" ]; then
REPODIR=.
else
if [ "$1" = "-stash" ]; then
CMD=stash
else
REPODIR=$1
fi
fi
if [ -n "$2" ]; then
if [ "$2" = "-stash" ]; then
CMD=stash
else
REPODIR=$2
fi
fi
for gitrepo in `find $REPODIR -name ".git" -execdir pwd \;`
do
cd "$gitrepo"
pwd
if [ -z "$CMD" ]; then
defaultStatus
else
stashStatus
fi
done
cd $OLDPWD