| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | . "$(dirname "$0")/testlib.sh" |
| 4 | reponame="submodule-test-repo" |
| 5 | submodname="submodule-test-submodule" |
| 6 | |
| 7 | begin_test "submodule local git dir" |
| 8 | ( |
| 9 | set -e |
| 10 | |
| 11 | setup_remote_repo "$reponame" |
| 12 | setup_remote_repo "$submodname" |
| 13 | |
| 14 | clone_repo "$submodname" submod |
| 15 | mkdir dir |
| 16 | echo "sub module" > dir/README |
| 17 | git add dir/README |
| 18 | git commit -a -m "submodule readme" |
| 19 | git push origin main |
| 20 | |
| 21 | clone_repo "$reponame" repo |
| 22 | git submodule add "$GITSERVER/$submodname" sub |
| 23 | git submodule update |
| 24 | git add .gitmodules sub |
| 25 | git commit -m "add submodule" |
| 26 | git push origin main |
| 27 | |
| 28 | grep "sub module" sub/dir/README || { |
| 29 | echo "submodule not setup correctly?" |
| 30 | cat sub/dir/README |
| 31 | exit 1 |
| 32 | } |
| 33 | ) |
| 34 | end_test |
| 35 | |
| 36 | begin_test "submodule env" |
| 37 | ( |
| 38 | set -e |
| 39 | |
| 40 | # using the local clone from the above test |
| 41 | cd repo |
| 42 | |
| 43 | git lfs env | tee env.log |
| 44 | grep "Endpoint=$GITSERVER/$reponame.git/info/lfs (auth=none)$" env.log |
| 45 | grep "LocalWorkingDir=$(canonical_path_escaped "$TRASHDIR/repo$")" env.log |
| 46 | grep "LocalGitDir=$(canonical_path_escaped "$TRASHDIR/repo/.git$")" env.log |
| 47 | grep "LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/repo/.git$")" env.log |
| 48 | grep "LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/lfs/objects$")" env.log |
| 49 | grep "TempDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/lfs/tmp$")" env.log |
| 50 | |
| 51 | cd .git |
| 52 | |
| 53 | echo "./.git" |
| 54 | git lfs env | tee env.log |
| 55 | cat env.log |
| 56 | grep "Endpoint=$GITSERVER/$reponame.git/info/lfs (auth=none)$" env.log |
| 57 | grep "LocalWorkingDir=$" env.log |
| 58 | grep "LocalGitDir=$(canonical_path_escaped "$TRASHDIR/repo/.git$")" env.log |
| 59 | grep "LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/repo/.git$")" env.log |
| 60 | grep "LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/lfs/objects$")" env.log |
| 61 | grep "TempDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/lfs/tmp$")" env.log |
| 62 | |
| 63 | cd ../sub |
| 64 | |
| 65 | echo "./sub" |
| 66 | git lfs env | tee env.log |
| 67 | grep "Endpoint=$GITSERVER/$submodname.git/info/lfs (auth=none)$" env.log |
| 68 | grep "LocalWorkingDir=$(canonical_path_escaped "$TRASHDIR/repo/sub$")" env.log |
| 69 | grep "LocalGitDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub$")" env.log |
| 70 | grep "LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub$")" env.log |
| 71 | grep "LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub/lfs/objects$")" env.log |
| 72 | grep "TempDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub/lfs/tmp$")" env.log |
| 73 | |
| 74 | cd dir |
| 75 | |
| 76 | echo "./sub/dir" |
| 77 | git lfs env | tee env.log |
| 78 | grep "Endpoint=$GITSERVER/$submodname.git/info/lfs (auth=none)$" env.log |
| 79 | grep "LocalWorkingDir=$(canonical_path_escaped "$TRASHDIR/repo/sub$")" env.log |
| 80 | grep "LocalGitDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub$")" env.log |
| 81 | grep "LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub$")" env.log |
| 82 | grep "LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub/lfs/objects$")" env.log |
| 83 | grep "TempDir=$(canonical_path_escaped "$TRASHDIR/repo/.git/modules/sub/lfs/tmp$")" env.log |
| 84 | ) |
| 85 | end_test |