blob: 28cd9cf0e70949edda930788b107daed5313379a (
plain) (
blame)
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
# Setup: Add src directory to PATH and create isolated test directory
SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../src" && pwd)"
export PATH="$SRCDIR:$PATH"
TESTDIR=$(mktemp -d)
trap "rm -rf '$TESTDIR'" EXIT
cd "$TESTDIR"
echo "=== Test: recursive subgit ==="
# Step 1: Create two upstream repositories
mkdir -p upstream/repo1 upstream/repo2
cd upstream/repo1
git init
echo "test1" > file1.txt
git add file1.txt
git commit -m "Initial commit repo1"
cd ../repo2
git init
echo "test2" > file2.txt
git add file2.txt
git commit -m "Initial commit repo2"
cd "$TESTDIR"
# Step 2: Create parent repo with a subrepo that itself has a nested subrepo
mkdir parent
cd parent
git init
# Add first-level subrepo
subgit add "$TESTDIR/upstream/repo1" subrepo1
# Make the subrepo directory into a subgit container with its own subrepo
cd subrepo1
git init
subgit add "$TESTDIR/upstream/repo2" nested-repo
cd "$TESTDIR/parent"
# Step 3: Test that init without -r flag does not initialize nested subrepos
echo "=== Test: init without -r flag ==="
rm -rf subrepo1/nested-repo
subgit init -f subrepo1
# nested-repo should not exist (not initialized recursively)
if [ -d subrepo1/nested-repo ]; then
echo "FAIL: nested repo should not be initialized without -r flag"
exit 1
fi
# Step 4: Test that init with -r flag initializes nested subrepos
echo "=== Test: init with -r flag ==="
subgit init -r -f subrepo1
# nested-repo should now exist with its files
if [ ! -f subrepo1/nested-repo/file2.txt ]; then
echo "FAIL: nested repo not initialized with -r flag"
exit 1
fi
# Verify .git symlink was created for nested repo
if [ ! -L subrepo1/nested-repo/.git ]; then
echo "FAIL: nested repo .git symlink not created"
exit 1
fi
echo "PASS: recursive test"
|