forked from remotemobprogramming/mob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-testbed
executable file
·73 lines (57 loc) · 1.67 KB
/
create-testbed
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
#!/bin/bash
set -e
cleanrepo() {
dir=$1
echo ""
echo "cleanrepo: Delete ${dir}"
rm -rf "${dir}"
}
createremoterepo() {
dir=$1
echo ""
echo "createremoterepo: Creating remote repository ${dir}"
mkdir -p "${dir}"
(cd "${dir}" && git --bare init && git symbolic-ref HEAD "refs/heads/${branch}")
}
clonerepo() {
dir=$1
echo ""
echo "clonerepo: Cloning remote ${remotedir} to ${dir}"
name=$(basename "${dir}")
mkdir -p "${dir}"
(cd "${dir}" && git clone --origin origin "file://${remotedir}" .)
(cd "${dir}" && git config --local user.name "${name}")
(cd "${dir}" && git config --local user.email "${name}@example.com")
}
tmpdir=$1
localdir="${tmpdir}/local"
remotedir="${tmpdir}/remote"
notgit="${tmpdir}/notgit"
branch=master # fixed to master for now
# create base dir
echo ""
echo "Creating temporary test assets in ${tmpdir}"
mkdir -p "${tmpdir}"
echo "create remote repo"
cleanrepo "${remotedir}"
createremoterepo "${remotedir}"
echo "create first local repo"
cleanrepo "${localdir}"
clonerepo "${localdir}"
echo "Populating and initial import pushing"
(cd "${localdir}" && echo "test" >test.txt && mkdir -p subdir && echo "subdir" >subdir/subdir.txt)
(cd "${localdir}" && git checkout -b "${branch}" && git add . && git commit --message "initial import" && git push --set-upstream --all origin)
echo "Creating more local repos"
for name in localother alice bob
do
cleanrepo "${tmpdir}/${name}"
clonerepo "${tmpdir}/${name}"
echo "Created local repo ${name}"
done
echo "Creating non-git dirs"
for dir in "${localdir}" "${notgit}"
do
mkdir -p "${dir}"
echo "Created non-git dir ${dir}"
done
echo "Done."