-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetupRepos.sh
More file actions
executable file
·75 lines (67 loc) · 2.66 KB
/
setupRepos.sh
File metadata and controls
executable file
·75 lines (67 loc) · 2.66 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#/--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
# __ __ _ _____ _ _ __ __ _ _ _
# \ \ / / | | | __ \ | | | | | \/ | | | | | | |
# \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
# \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
# \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
# \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
# | |
# |_|
#/-------------------------------------------------------------------------------------------------------------------------------/
#
# @author Llewellyn van der Merwe <https://github.com/Llewellynvdm>
# @copyright Copyright (C) 2016. All Rights Reserved
# @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
#
#/-----------------------------------------------------------------------------------------------------------------------------/
# get script path
scriptPath="${BASH_SOURCE%/*}"
if [[ ! -d "$scriptPath" || "$scriptPath" == '.' ]]; then scriptPath="$PWD"; fi
# load notify
. "${scriptPath}/notify.sh"
# go to script path
cd "${scriptPath}"
# go one dir up
cd ../
# go to repositories directory
DIR="$PWD/VDM/REPOS"
if [ ! -d "$DIR" ]
then
mkdir -p "$DIR"
fi
## setup forked repos to be able to sync with upstream
function setForkedRepos () {
# ensure repos is already set
cd "$DIR"
if [ ! -d "$DIR/$1/$3" ]
then
# ensure the github user folder is set
if [ ! -d "$DIR/$1" ]
then
mkdir -p "$DIR/$1"
fi
cd "$DIR/$1"
# keep local repo small
git clone --depth 3 "$2"
cd "$DIR/$1/$3"
# set upstream branch
git remote add upstream "$4"
# move back to script path
cd "${scriptPath}"
# also inform me
notifyMe "Just added $1's $3 repo."
fi
}
# only run for repos have been set
if [ -f "${scriptPath}/repos" ]; then
# array of repos
readarray -t REPOS < "${scriptPath}/repos"
for update in "${REPOS[@]}"; do
repo=($update)
setForkedRepos ${repo[0]} ${repo[1]} ${repo[2]} ${repo[3]}
done
else
echo "You must first run the getRepos.sh before you continue."
exit 1
fi