Skip to content

Commit 44c8058

Browse files
committed
Generate test git-repos instead of committed binaries
Instead of having test repos: foo, bar and init committed in a binary form, generate them using the test/gen* scripts before starting the first 'test' session. Running 'make clean' removes the generated test repos.
1 parent 44660be commit 44c8058

File tree

5 files changed

+130
-1
lines changed

5 files changed

+130
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ compgen: force
110110
$(SHARE)/zsh-completion/_git-subrepo
111111

112112
clean:
113-
rm -fr tmp test/tmp
113+
rm -fr tmp test/tmp test/repo
114114

115115
define docker-make-test
116116
docker run --rm \

test/genbar

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -xe
3+
4+
if [ -z "${1}" ]; then
5+
echo "${BASH_SOURCE[0]}: Single argument required (common test repos path)"
6+
exit 1
7+
fi
8+
9+
REPO="bar"
10+
NAME="Bar"
11+
TARGET="${1}/$REPO"
12+
TMPREPO="${1}/tmp/$REPO"
13+
14+
rm -rf "$TMPREPO"
15+
mkdir -p "$TMPREPO"
16+
cd "$TMPREPO"
17+
git init --initial-branch=master .
18+
git config user.name "${NAME}User"
19+
git config user.email "${REPO}@${REPO}"
20+
touch $NAME
21+
git add $NAME
22+
git commit -m"$NAME"
23+
git tag A -m"$NAME"
24+
mkdir -p bard
25+
touch bard/Bard
26+
git add bard
27+
git commit -m"bard/Bard"
28+
git config --bool core.bare true
29+
cd -
30+
mkdir -p "$1"
31+
mv "$TMPREPO/.git" "$TARGET"

test/genfoo

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -xe
3+
4+
if [ -z "${1}" ]; then
5+
echo "${BASH_SOURCE[0]}: Single argument required (common test repos path)"
6+
exit 1
7+
fi
8+
9+
REPO="foo"
10+
NAME="Foo"
11+
TARGET="${1}/$REPO"
12+
TMPREPO="${1}/tmp/$REPO"
13+
14+
rm -rf "$TMPREPO"
15+
mkdir -p "$TMPREPO"
16+
cd "$TMPREPO"
17+
git init --initial-branch=master .
18+
git config user.name "${NAME}User"
19+
git config user.email "${REPO}@${REPO}"
20+
touch $NAME
21+
git add $NAME
22+
git commit -m"$NAME"
23+
git config --bool core.bare true
24+
cd -
25+
mkdir -p "$1"
26+
mv "${TMPREPO}/.git" "$TARGET"

test/geninit

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
set -xe
3+
4+
if [ -z "${1}" ]; then
5+
echo "${BASH_SOURCE[0]}: Single argument required (common test repos path)"
6+
exit 1
7+
fi
8+
9+
REPO="init"
10+
NAME="Init"
11+
TARGET="${1}/$REPO"
12+
TMPREPO="${1}/tmp/$REPO"
13+
14+
rm -rf "$TMPREPO"
15+
mkdir -p "$TMPREPO"
16+
cd "$TMPREPO"
17+
git init --initial-branch=master .
18+
git config user.name "${NAME}User"
19+
git config user.email "${REPO}@${REPO}"
20+
cat <<EOF > ReadMe
21+
This is a repo to test \`git subrepo init\`.
22+
23+
We will make a short history with a subdir, then we can turn that subdir into a
24+
subrepo.
25+
EOF
26+
git add ReadMe
27+
git commit -m"Initial commit"
28+
mkdir -p doc
29+
cat <<EOF > doc/init.swim
30+
== Subrepo Init!
31+
32+
This is a file to test the \`git subrepo init\` command.
33+
EOF
34+
git add doc
35+
git commit -m"Add a file in a subdir."
36+
cat <<EOF >> ReadMe
37+
38+
This repo will go in the git-subrepo test suite.
39+
EOF
40+
git add ReadMe
41+
git commit -m"Add a commit to the mainline."
42+
cat <<EOF >> doc/init.swim
43+
44+
It lives under the doc directory which will become a subrepo.
45+
EOF
46+
git add doc/init.swim
47+
git commit -m"Add a commit to the subdir."
48+
cat <<EOF >> ReadMe
49+
50+
EOF
51+
git add ReadMe
52+
cat <<EOF >> doc/init.swim
53+
54+
EOF
55+
git add doc/init.swim
56+
git commit -m"Add a commit that affects both."
57+
git config --bool core.bare true
58+
cd -
59+
mkdir -p "$1"
60+
mv "${TMPREPO}/.git" "$TARGET"

test/setup

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ if [ ! -d "${SCRIPT_DIR}/../.git" ]; then
1818
git config --list
1919
fi
2020

21+
# Generate additional testing git repos, if not already present.
22+
mkdir -p "${SCRIPT_DIR}/repo"
23+
if [ ! -d "${SCRIPT_DIR}/repo/bar" ]; then
24+
"${SCRIPT_DIR}/genbar" "${SCRIPT_DIR}/repo"
25+
fi
26+
if [ ! -d "${SCRIPT_DIR}/repo/foo" ]; then
27+
"${SCRIPT_DIR}/genfoo" "${SCRIPT_DIR}/repo"
28+
fi
29+
if [ ! -d "${SCRIPT_DIR}/repo/init" ]; then
30+
"${SCRIPT_DIR}/geninit" "${SCRIPT_DIR}/repo"
31+
fi
32+
2133
BASHLIB=$(
2234
find "$PWD"/ -type d -name bin -o -type d -name lib | grep -v "\/\.pc\/" | tr '\n' ':'
2335
)

0 commit comments

Comments
 (0)