repo-cloner/tests/_support_data/gen-data.sh
Václav Valíček 7becb2450f
Gen data updated
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-08-09 21:25:45 +02:00

94 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
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
git init tool_repos/non-bare-init
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
git branch -D test-head || true
cd ..
done
# recover submodules to initial state (branches will remain)
git submodule update --init
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