-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull_dependencies.sh
executable file
·41 lines (38 loc) · 1.27 KB
/
pull_dependencies.sh
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
#!/bin/bash
# @author Manuel Gieseking
IFS=',' read -r -a dep_folders <<< "$1"
IFS=',' read -r -a dep_repos <<< "$2"
IFS=',' read -r -a dep_rev <<< "$3"
PREFIX="dependencies"
if [ ! -d "$PREFIX" ]; then
echo "Creating the folder '$PREFIX'."
mkdir $PREFIX
fi
cd $PREFIX
count=0
for dep in "${dep_folders[@]}" # all dependencies
do
echo "%%%%%%%%%%%%%%%% DEPENDENCY: $dep"
if [ -d "$dep" ]; then
cd $dep
echo "Start pulling the git repository ${dep_repos[$count]}"
if [[ ${dep_rev[$count]} != 'HEAD' ]]; then
git checkout master # if you don't want to checkout the HEAD revision, first go back to master
fi
git pull # then pull,
if [[ ${dep_rev[$count]} != 'HEAD' ]]; then
git checkout ${dep_rev[$count]} # and then checkout the specific revision
fi
cd ..
else
# The dependency is missing checkout the corresponding repo
echo "The dependency '$PREFIX/$dep' does not exist."
echo "Start cloning the git repository ${dep_repos[$count]}"
git clone ${dep_repos[$count]}
if [[ ${dep_rev[$count]} != 'HEAD' ]]; then
git checkout ${dep_rev[$count]}
fi
fi
count=$(($count+1));
done
cd ..