forked from openedx-unsupported/devstack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
repo.sh
executable file
·78 lines (67 loc) · 2.03 KB
/
repo.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
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
76
77
78
#!/usr/bin/env bash
set -e
set -o pipefail
# Script for Git repos housing edX services. These repos are mounted as
# data volumes into their corresponding Docker containers to facilitate development.
# Repos are cloned to/removed from the directory above the one housing this file.
if [ -z "$DEVSTACK_WORKSPACE" ]; then
echo "need to set workspace dir"
exit 1
elif [ -d "$DEVSTACK_WORKSPACE" ]; then
cd $DEVSTACK_WORKSPACE
else
echo "Workspace directory $DEVSTACK_WORKSPACE doesn't exist"
exit 1
fi
repos=(
"https://github.com/edx/course-discovery.git"
"https://github.com/edx/credentials.git"
"https://github.com/edx/cs_comments_service.git"
"https://github.com/edx/ecommerce.git"
"https://github.com/edx/edx-e2e-tests.git"
"https://github.com/edx/edx-platform.git"
)
name_pattern=".*edx/(.*).git"
clone ()
{
for repo in ${repos[*]}
do
# Use Bash's regex match operator to capture the name of the repo.
# Results of the match are saved to an array called $BASH_REMATCH.
[[ $repo =~ $name_pattern ]]
name="${BASH_REMATCH[1]}"
if [ -d "$name" ]; then
printf "The [%s] repo is already checked out. Continuing.\n" $name
else
if [ "${SHALLOW_CLONE}" == "1" ]; then
git clone --depth=1 $repo
else
git clone $repo
fi
fi
done
cd - &> /dev/null
}
reset ()
{
currDir=$(pwd)
for repo in ${repos[*]}
do
[[ $repo =~ $name_pattern ]]
name="${BASH_REMATCH[1]}"
if [ -d "$name" ]; then
cd $name;git reset --hard HEAD;git checkout master;git pull;cd "$currDir"
else
printf "The [%s] repo is not cloned. Continuing.\n" $name
fi
done
cd - &> /dev/null
}
if [ "$1" == "clone" ]; then
clone
elif [ "$1" == "reset" ]; then
read -p "This will override any uncommited changes in your local git checkouts. Would you like to proceed? [y/n] " -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
reset
fi
fi