-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-src
executable file
·53 lines (45 loc) · 1.74 KB
/
init-src
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
#!/bin/zsh
#─────────────────────────────────────────────────────────────────
# Retrieve various sources
#
# author: Ludovic Vigouroux <ludo@mundoludo.fr>
# created: December 2011
# Free to use, modify and redistribute.
#─────────────────────────────────────────────────────────────────
setopt null_glob
#─────────────────────────────────────────────────────────────────
# Clone sources
#─────────────────────────────────────────────────────────────────
retrieve_src() {
local destination
local dir
for project in ${(ok)src}; do
print -- $project
if [[ -n $src_destination && -n $src_destination[$project] ]]; then
destination=$treepathslabel[$src_destination[$project]]
else
destination=$src_path
fi
dir=$destination/$project
echo location: $dir
if [[ -d $dir ]]; then
files=($dir/*)
if [[ ${#files[@]} -gt 0 ]]; then
cd $dir && git pull
else
rmdir $dir && git clone $src[$project] $dir
fi
else
git clone $src[$project] $dir
fi
done
}
# retrieve this file location
script_location=${0:A:h}
# read config command
. $script_location/load-config src src_destination $*
# load directories path
. $script_location/traverse-tree -q $*
src_path=$treepathslabel[src]
retrieve_src
# vim: set filetype=zsh: