-
Notifications
You must be signed in to change notification settings - Fork 31
/
clone_docs.sh
executable file
·60 lines (46 loc) · 1.55 KB
/
clone_docs.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
#!/usr/bin/env bash
set -e
# Allows for glob in mv commands, needed to exclude `docs` folder
shopt -s extglob
# Clones the `docs` folder of each stryker repository
function git_clone_docs() (
remoteUrl="https://github.com/stryker-mutator/$1.git"
localdir="$1"
cd docs
# Update folder if it already exists
if [ -d $localdir ]
then
echo "$1 already exists. Updating..."
cd $localdir
# Move files back into docs to pull
mv !(docs) docs
else
echo "Cloning $localdir..."
# Else create new empty git repository and pull only docs folder to it
if [ -n "$2" ]; then
git clone --branch $2 $remoteUrl $localdir --depth 1 --no-checkout
else
git clone $remoteUrl $localdir --depth 1 --no-checkout
fi
cd "$localdir"
# Tell git to only checkout docs folder
git sparse-checkout init --cone
git sparse-checkout set 'docs'
defaultBranch="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
checkoutBranch=${2:-$defaultBranch}
git checkout $checkoutBranch
# Remove everything in the root that is not in docs
rm !(docs)
fi
defaultBranch="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
checkoutBranch=${2:-$defaultBranch}
git pull origin $checkoutBranch
mv docs/* .
cd ../
)
# cloning a different branch works like: git_clone_docs "stryker-net" "v1.0"
git_clone_docs "stryker-js"
git_clone_docs "mutation-testing-elements"
rm -rf docs/mutation-testing-elements/packages
git_clone_docs "stryker4s"
git_clone_docs "stryker-net"