-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-up-all
executable file
·45 lines (36 loc) · 1.06 KB
/
git-up-all
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
#!/bin/zsh
# make it beautiful
autoload colors ; colors
GIT=`which git`
folders=(/srv/modules /srv/httpd ~) # entry points for git folder search
git_dirs=() # git directories
maxdepth=3 # folder depth for entry points
# check for git up command
git up --version &> /dev/null
if [ $? -eq 1 ]; then
echo "$fg[red]error$reset_color: git-up is required (https://github.com/aanand/git-up)\n"
exit 1
fi
update()
{
output=`$GIT --git-dir=$1/.git --work-tree=$1 up 2>&1`
echo "update $fg[yellow]$1$reset_color:"
echo "$output\n"
}
# find git folders in project directories
for folder in $folders; do
for dir in $(find "$folder" -maxdepth $maxdepth -mindepth 2 -type d -name .git); do
if [[ ! -z $(git --git-dir=$dir remote) ]]; then
git_dirs+=(${dir/\/.git/})
else
echo "skip $dir"
fi
done
done
echo "found $fg[yellow]${#git_dirs}$reset_color directories.\n"
# update all directories
for directory in $git_dirs; do
update $directory & # "&" fork of to be faster
done
# wait for all forked jobs
wait