- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitUpdate
More file actions
Latest commit
executable file
·58 lines (51 loc) · 1.96 KB
/
Copy pathgitUpdate
File metadata and controls
executable file
·58 lines (51 loc) · 1.96 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
#!/bin/bash
## -------------------------------------------------------------------
## Git Remote Fetcher 1.0.0
##
## This is free software: you are free to change and redistribute it.
## There is NO WARRANTY, to the extent permitted by law.
## -------------------------------------------------------------------
### Fetches changes from all remotes in all repositories
### Usage: gitUpdate [options] [--ignore-remote <remote>]...
###
### -q, --quiet Quiets the output.
### -i, --ignore-remote <remote> Ignores the given remote when updating.
### -h, --help Show help options.
### -v, --version Print program version.
help=$(grep "^### ""$0"| cut -c 5-)
version=$(grep "^## ""$0"| cut -c 4-)
eval"$(docopts -A args -h "$help" -V "$version":"$@")"
i=0
IGNORES=""
while [[ $i-lt${args[--ignore-remote,#]} ]];do
IGNORES="$IGNORES${args[--ignore-remote,$i]}"
i=$[$i+1]
done
.$(dirname $0)/scriptsConfig
cd$GITDIR
forFILEin`ls`;do
if [ -d$FILE ];then
cd$FILE
if [ -e'.git' ];then
if [[ -n$RSAKEYLOC ]] && [[ $(ssh-add -l)!=*"$HOME/.ssh/id_rsa"* ]];then
ssh-add
fi
if${args[--quiet]};then
git fetch --all --quiet 2>/dev/null
else
forREMOTEin`git remote`;do
if [[ -z$(echo $IGNORES| egrep "\b$REMOTE\b") ]];then
echo"Fetching remote $REMOTE in $FILE."
OUTPUT=$(git fetch $REMOTE2>&1)
if [ $?-ne 0 ];then
echo -e "\e[31m ERROR: Fetching of $REMOTE in $FILE failed.\e[m"
elif [[ $OUTPUT=*"->"* ]];then
echo -e "\e[36m Fetched from $REMOTE in $FILE.\e[m"
fi
fi
done
fi
fi
cd ..
fi
done