Skip to content

Commit 56148ae

Browse files
author
Rafael Basask
committed
manage git repositories in batch mode
1 parent 39178d8 commit 56148ae

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

kkgit

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
PROTOCOL_COL="\033[1m\e[37;40m"
4+
5+
HTTP_COL="\e[32m"
6+
SSH_COL="\e[33m"
7+
8+
ERR_COL="\e[37;41m"
9+
RESET_COL="\033[0m\e[0m"
10+
11+
confirm () {
12+
read -r -p "${1:-Wanna Update? [y/N]} " choose
13+
case $choose in
14+
[yY][eE][sS]|[yY])
15+
true
16+
;;
17+
*)
18+
false
19+
;;
20+
esac
21+
}
22+
23+
function gitpath {
24+
REMOTE=`git config --get remote.origin.url`
25+
MSG=""
26+
COL=$ERR_COL
27+
if [[ $REMOTE == ssh* ]]; then
28+
COL=$SSH_COL
29+
MSG="SSH"
30+
elif [[ $REMOTE == "http"* ]]; then
31+
COL=$HTTP_COL
32+
MSG="HTTP"
33+
else
34+
COL=$ERR_COL
35+
MSG="UNKNOWN"
36+
fi
37+
echo -e "$PROTOCOL_COL $MSG $RESET_COL $COL $REMOTE $RESET_COL"
38+
}
39+
40+
41+
RESP=0
42+
confirm "Auto confirm? [y/N]" && RESP=1
43+
44+
for i in `find . -name '.git'`
45+
do
46+
DIR=$(dirname "${i}")
47+
48+
cd $DIR
49+
50+
gitpath
51+
52+
if [ $RESP -eq 1 ]; then
53+
git $*
54+
else
55+
confirm "Execute? [y/N]" && git $*
56+
fi
57+
58+
cd - > /dev/null
59+
done

0 commit comments

Comments
 (0)