blob: 00d2cf7f655dfff568981c17e33adb1edeb55de5 (
plain) (
blame)
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
|
#!/bin/sh
columate() {
_str="$1"
_max_length=48
_length=$( printf "%s" $_str | wc -c)
# Divide by 8, because that's the standard tabstop
_tab_num=$(echo "($_max_length-$_length)/8" | bc -l )
_tabs=""
# Create the tabs
for _tab in $( seq $_tab_num ) ; do
_tabs="$(printf "%s\t" $_tabs)"
done
# "Return" the tabs
printf "%s" $_tabs
}
REPOS="$(find . -iname .git -type d | sed -e's/\/\.git$//' -e's_./__')"
WD="$(pwd)"
IFS='
'
echo '#!/bin/sh
WD="$(pwd)"
clone() {
printf "\033[0mWorking dir: \033[1;34m%s\033[0;33m\n" $DIR
if [ -d "$DIR" ] ; then
cd $DIR
git pull --ff-only origin master
elif ! [ -d "$DIR" ] ; then
mkdir -p "$DIR"
cd "$DIR"
git clone "$URL" .
fi
cd $WD
}' > setup.sh
for _repo in $REPOS; do
cd "$_repo"
# I've probably made dangerous assumptions here, but whatever.
URL="$(git remote --verbose| awk '{print $2}' | sort | uniq | head -n 1)"
cd "$WD"
_tabs="$(columate $_repo)"
printf 'Added: \033[1;33m%s\033[0m%sURL: \033[1;34m%s\033[0m\n' \
$_repo $_tabs $URL
printf 'DIR="%s"\nURL="%s"\nclone\n' $_repo $URL >> setup.sh
done
chmod +x setup.sh
|