2022-05-04 10:52:07 +02:00
|
|
|
#!/bin/bash
|
2022-07-26 20:13:04 +02:00
|
|
|
|
|
|
|
new_pwd=$(dirname $(realpath $0))
|
|
|
|
cd $new_pwd
|
|
|
|
|
|
|
|
# remove old data, if exists
|
|
|
|
if [ -d "tool_repos" ]
|
|
|
|
then
|
|
|
|
echo "Removing old tool_repos"
|
|
|
|
rm -Rf "tool_repos"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Initializing tool_repos"
|
|
|
|
mkdir -p tool_repos/uninitialized.git
|
|
|
|
git init --bare tool_repos/initialized.git
|
2022-07-26 22:04:51 +02:00
|
|
|
git init tool_repos/non-bare-init
|
2022-07-26 20:13:04 +02:00
|
|
|
|
2022-07-27 10:23:50 +02:00
|
|
|
echo "Preparing submodules for tests.."
|
|
|
|
for repo in test-repo-*
|
|
|
|
do
|
|
|
|
echo ">> $repo"
|
|
|
|
cd $repo
|
|
|
|
for i in $(git for-each-ref --format="%(refname:short)" --no-merged=origin/HEAD refs/remotes/origin); do git switch --track $i; done
|
2022-08-09 21:25:45 +02:00
|
|
|
git branch -D test-head || true
|
2022-07-27 10:23:50 +02:00
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
# recover submodules to initial state (branches will remain)
|
|
|
|
git submodule update --init
|
2022-07-30 20:29:59 +02:00
|
|
|
|
|
|
|
if [ -d test-submodules-adhoc ]
|
|
|
|
then
|
|
|
|
echp "Removing adhoc submodules"
|
|
|
|
rm -Rf test-submodules-adhoc
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating adhoc submodules"
|
|
|
|
mkdir test-submodules-adhoc
|
|
|
|
cd test-submodules-adhoc
|
|
|
|
|
|
|
|
# git submodules level two
|
|
|
|
git init submodules-level-two
|
|
|
|
cd submodules-level-two
|
|
|
|
git config user.name Tester
|
|
|
|
git config user.email test@tester.me
|
|
|
|
git submodule add $new_pwd/test-repo-base
|
|
|
|
git submodule add $new_pwd/test-repo-reduced
|
|
|
|
git add -A
|
|
|
|
git commit -m "first commit"
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
# git submodules root level
|
|
|
|
git init submodules-root
|
|
|
|
cd submodules-root
|
|
|
|
git config user.name Tester
|
|
|
|
git config user.email test@tester.me
|
|
|
|
git submodule add $new_pwd/test-repo-base
|
|
|
|
git submodule add $new_pwd/test-repo-different-tags
|
|
|
|
git add -A
|
|
|
|
git commit -m "initial commit"
|
|
|
|
git submodule add $new_pwd/test-repo-new-commits
|
|
|
|
git submodule add $new_pwd/test-submodules-adhoc/submodules-level-two
|
|
|
|
git add -A
|
|
|
|
git commit -m "added submodule recursion"
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
|
|
|
|
# submodule with failed url
|
|
|
|
git init submodule-failed-cfg
|
|
|
|
cd submodule-failed-cfg
|
|
|
|
git config user.name Tester
|
|
|
|
git config user.email test@tester.me
|
|
|
|
echo "# komentář" > .gitmodules
|
|
|
|
dd if=/dev/urandom bs=20 count=1 > .gitmodules
|
|
|
|
git add -A
|
|
|
|
git commit -m "failed .gitmodules"
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
# submodule root with two fucked-up submodules
|
|
|
|
git init submodule-failed
|
|
|
|
cd submodule-failed
|
|
|
|
git config user.name Tester
|
|
|
|
git config user.email test@tester.me
|
|
|
|
git submodule add $new_pwd/test-submodules-adhoc/submodule-failed-cfg
|
|
|
|
git submodule add $new_pwd/test-repo-base
|
|
|
|
git submodule deinit test-repo-base
|
|
|
|
sed -i 's/_support_data\/test-repo-base/_support_\/test-repo-base/g' .gitmodules
|
|
|
|
git add -A
|
|
|
|
git commit -m "submodules created, but would fail"
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
|
|
|
|
# return back
|
|
|
|
cd $new_pwd
|