2024-06-27 11:48:54 +00:00
|
|
|
#!/bin/bash
|
2024-06-28 16:29:11 +00:00
|
|
|
Help()
|
|
|
|
{
|
|
|
|
echo "
|
|
|
|
NAME
|
|
|
|
creation_repo.sh
|
|
|
|
SYNOPSIS
|
2024-07-08 08:28:35 +00:00
|
|
|
creation_repo.sh [-h] [-s]
|
2024-06-28 16:29:11 +00:00
|
|
|
DESCRIPTION
|
2024-07-17 08:37:39 +00:00
|
|
|
This script creates a ./remote directory in the current directory, then creates a remote/performance_testing git repository.
|
2024-07-08 08:28:35 +00:00
|
|
|
This git repository is filled with randomly generated binary files described in the readme.md.
|
2024-06-28 16:29:11 +00:00
|
|
|
OPTIONS
|
2024-07-08 08:28:35 +00:00
|
|
|
-h prints the help.
|
2024-07-17 08:37:39 +00:00
|
|
|
-l [link] adds the linked online repository as remote and pushes changes to it. Must be en empty repository.
|
2024-07-08 08:28:35 +00:00
|
|
|
-s creates a submodule remote/submodule_for_performance_testing and includes it in remote/performance_testing. "
|
|
|
|
}
|
|
|
|
|
|
|
|
create_random_file(){
|
2024-07-17 08:37:39 +00:00
|
|
|
dd if=/dev/urandom of=$1 bs=$2 count=1 &> /dev/null
|
2024-06-28 16:29:11 +00:00
|
|
|
}
|
2024-07-08 08:28:35 +00:00
|
|
|
|
2024-07-23 19:06:51 +00:00
|
|
|
REPO_NAME=git_update_testing
|
2024-07-08 08:28:35 +00:00
|
|
|
REPO_PATH=./remote
|
2024-07-08 14:18:37 +00:00
|
|
|
WITH_SUBMODULE="false"
|
2024-07-23 19:06:51 +00:00
|
|
|
SUB_NAME="submodule"
|
2024-07-17 08:37:39 +00:00
|
|
|
WITH_LINK="false"
|
|
|
|
while getopts ":hn:sl:" option; do
|
2024-06-28 16:29:11 +00:00
|
|
|
case $option in
|
2024-07-08 08:28:35 +00:00
|
|
|
h)
|
2024-06-28 16:29:11 +00:00
|
|
|
Help
|
|
|
|
exit;;
|
2024-07-17 08:37:39 +00:00
|
|
|
n)
|
|
|
|
REPO_NAME=$OPTARG;;
|
|
|
|
s)
|
2024-07-08 08:28:35 +00:00
|
|
|
WITH_SUBMODULE="true";;
|
2024-07-17 08:37:39 +00:00
|
|
|
l)
|
|
|
|
WITH_LINK="true"
|
|
|
|
LINK=$OPTARG;;
|
2024-07-08 08:28:35 +00:00
|
|
|
\?)
|
2024-06-28 16:29:11 +00:00
|
|
|
echo "Error: Invalid option"
|
|
|
|
exit;;
|
|
|
|
esac
|
|
|
|
done
|
2024-06-27 11:48:54 +00:00
|
|
|
|
2024-07-03 12:51:49 +00:00
|
|
|
if [ ! -d $REPO_PATH ]; then
|
|
|
|
mkdir $REPO_PATH
|
|
|
|
fi
|
|
|
|
cd $REPO_PATH
|
|
|
|
if [ ! -d $REPO_NAME ]; then
|
2024-07-17 09:54:29 +00:00
|
|
|
echo "remote/performance testing will be created"
|
2024-07-03 12:51:49 +00:00
|
|
|
mkdir $REPO_NAME
|
|
|
|
cd $REPO_NAME
|
|
|
|
git init
|
|
|
|
git branch -m main
|
2024-07-04 16:29:55 +00:00
|
|
|
create_random_file 'sample0' '1M'
|
2024-07-03 12:51:49 +00:00
|
|
|
git add .
|
|
|
|
git commit -m"first 1M sample created"
|
2024-07-04 16:29:55 +00:00
|
|
|
create_random_file 'sample1' '1M'
|
2024-07-17 08:37:39 +00:00
|
|
|
git add sample1
|
2024-07-03 12:51:49 +00:00
|
|
|
git commit -m"second 1M sample created"
|
|
|
|
git branch secondary
|
|
|
|
git checkout secondary
|
2024-07-04 16:29:55 +00:00
|
|
|
create_random_file 'sample2' '500K'
|
2024-07-03 12:51:49 +00:00
|
|
|
git add sample2
|
|
|
|
git commit -m"first 500K sample created in branch secondary"
|
|
|
|
git checkout main
|
2024-07-04 16:29:55 +00:00
|
|
|
create_random_file 'sample4' '5M'
|
2024-07-03 12:51:49 +00:00
|
|
|
git add sample4
|
|
|
|
git commit -m"first 5M sample created"
|
2024-07-17 08:37:39 +00:00
|
|
|
git tag tagging_point
|
|
|
|
create_random_file 'sample3' '1M'
|
|
|
|
git add sample3
|
|
|
|
git commit -m"third 1M sample created"
|
2024-07-03 12:51:49 +00:00
|
|
|
rm sample4
|
|
|
|
git add sample4
|
|
|
|
git commit -m"sample4 deleted"
|
2024-07-08 08:28:35 +00:00
|
|
|
cd ..
|
|
|
|
if [ "$WITH_SUBMODULE" = "true" ]; then
|
2024-07-08 09:19:27 +00:00
|
|
|
mkdir $SUB_NAME
|
|
|
|
cd $SUB_NAME
|
|
|
|
git init
|
|
|
|
git branch -m main
|
|
|
|
create_random_file 'sub_sample0' '1M'
|
|
|
|
git add .
|
|
|
|
git commit -m"first 1M sample created"
|
|
|
|
cd ../$REPO_NAME
|
2024-07-23 19:06:51 +00:00
|
|
|
git submodule add ../$SUB_NAME
|
2024-07-06 15:43:57 +00:00
|
|
|
git commit -am "adding $SUB_NAME module"
|
|
|
|
fi
|
2024-07-05 07:47:37 +00:00
|
|
|
cd ..
|
2024-07-08 09:19:27 +00:00
|
|
|
else # $REPO_NAME exists
|
2024-07-17 08:37:39 +00:00
|
|
|
echo "remote/$REPO_NAME already exists"
|
2024-07-08 09:19:27 +00:00
|
|
|
if [[ "$WITH_SUBMODULE" = "true" && ! -d $SUB_NAME ]]; then
|
|
|
|
mkdir $SUB_NAME
|
|
|
|
cd $SUB_NAME
|
|
|
|
git init
|
|
|
|
git branch -m main
|
|
|
|
create_random_file 'sub_sample0' '1M'
|
|
|
|
git add .
|
|
|
|
git commit -m"first 1M sample created"
|
|
|
|
cd ../$REPO_NAME
|
2024-07-23 19:06:51 +00:00
|
|
|
git submodule add ../$SUB_NAME
|
2024-07-08 09:19:27 +00:00
|
|
|
git commit -am "adding $SUB_NAME module"
|
|
|
|
elif [[ "$WITH_SUBMODULE" != "true" && -d $SUB_NAME ]]; then
|
2024-07-08 14:18:37 +00:00
|
|
|
cd $REPO_NAME
|
|
|
|
git reset --hard HEAD~1 &> /dev/null
|
|
|
|
rm -rf $SUB_NAME &> /dev/null
|
2024-07-08 09:19:27 +00:00
|
|
|
cd ..
|
|
|
|
rm -rf $SUB_NAME
|
|
|
|
fi
|
2024-07-03 12:51:49 +00:00
|
|
|
fi
|
2024-07-17 08:37:39 +00:00
|
|
|
if [ "$WITH_LINK" = "true" ]; then
|
|
|
|
cd $REPO_NAME
|
|
|
|
if [ $(git remote | grep "origin" | wc -l) = 0 ]; then
|
|
|
|
echo "adding origin"
|
|
|
|
git remote add origin $LINK
|
|
|
|
git push origin -u --all
|
|
|
|
git push origin -u --tags
|
|
|
|
fi
|
|
|
|
fi
|
2024-07-08 09:19:27 +00:00
|
|
|
|
|
|
|
cd ..
|
|
|
|
|