test_fill_submodule.sh 1.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
# Test fill_submodule function
current_wd=$PWD

rm_mkdir tmp_repos
cd tmp_repos
mkdir project
(cd project && git init &&
    echo "Interesting!" > README.txt &&
    git add README.txt &&
    local_author &&
11
12
    git commit -m "first project" &&
    git tag first-commit)
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
mkdir superproject
cd superproject
git init
git submodule add ../project
local_author
git commit -m "first superproject"
# Check the submodule is working correctly before intervention
cd project
remote_url=$(git config --get remote.origin.url)
[ "$(git log --format="%s")" == "first project" ] || ingest "bad submodule"
[ -f .git ] || ingest "expecting .git to be a file"
cd ..
# Intervene
fill_submodule project
cd project
[ "$(git log --format="%s")" == "first project" ] || ingest "bad after filling"
[ -d .git ] || ingest "expecting .git to be a directory"
[ "$(git config --get remote.origin.url)" == "$remote_url" ] || ingest "bad remote"
31
# Check we can do a checkout of a branch
32
git checkout master
33
34
# Checkout a tag
git checkout first-commit
35
36
37
38
39
40
41
42
43
44
45
cd ..
# Intervene again (has .git directory now)
fill_submodule project
cd project
[ "$(git log --format="%s")" == "first project" ] || ingest "bad after refilling"
[ -d .git ] || ingest "expecting .git to be a directory"
[ "$(git config --get remote.origin.url)" == "$remote_url" ] || ingest "bad remote"
cd ..

cd "$current_wd"
rm -rf tmp_repos