-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sh
executable file
·30 lines (26 loc) · 969 Bytes
/
init.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
#!/usr/bin/env bash
set -o errexit # Exit script when a command exits with non-zero status.
set -o errtrace # Exit on error inside any functions or sub-shells.
set -o nounset # Exit script on use of an undefined variable.
set -o pipefail # Return exit status of the last command in the pipe that exited with a non-zero exit code
: readonly "${GIT:=git}"
init() {
mkdir -p master
mkdir -p editor
mkdir -p release
# get origin url
local origin="$(git config --get remote.origin.url)"
local root="${origin%/*}"
# get contexts from file
while read context; do
"${GIT}" clone --single-branch "${root}/${context}" "master/${context}"
"${GIT}" clone --single-branch "${root}/${context}" "release/${context}"
"${GIT}" clone --single-branch -b editor "${root}/${context}" "editor/${context}"
done < curriculum-contexts.txt
}
if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then
export -f init
else
init "${@}"
exit $?
fi