git_update/creation_repo.sh

86 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
. driglibash-base
Help()
{
echo "
NAME
creation_repo.sh
SYNOPSIS
creation_repo.sh [SSH LINK to en empty remote git repository]
DESCRIPTION
This script is in writing.
It creates a git repository in the current directory, linked to a remote passed as argument. Everything is up-to-date between the remote and the local versions. The data stored is generated randomly in binary.
OPTIONS
-h prints the help. "
}
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
while getopts ":h" option; do
case $option in
h) # display Help
Help
exit;;
\?) # Invalid option
echo "Error: Invalid option"
exit;;
esac
done
fi
create_random_file(){
run dd if=/dev/urandom of=$1 bs=$2 count=1 &> /dev/null
}
REPO_NAME=performance_testing
REPO_PATH=./remote
WITH_SUBMODULE="true"
if [ ! -d $REPO_PATH ]; then
mkdir $REPO_PATH
fi
cd $REPO_PATH
echo $(ls -la)
if [ ! -d $REPO_NAME ]; then
mkdir $REPO_NAME
cd $REPO_NAME
git init
git branch -m main
create_random_file 'sample0' '1M'
git add .
git commit -m"first 1M sample created"
git tag start
create_random_file 'sample1' '1M'
git add sample1
git commit -m"second 1M sample created"
git branch secondary
git checkout secondary
create_random_file 'sample2' '500K'
git add sample2
git commit -m"first 500K sample created in branch secondary"
git checkout main
create_random_file 'sample3' '1M'
git add sample3
git commit -m"third 1M sample created"
create_random_file 'sample4' '5M'
git add sample4
git commit -m"first 5M sample created"
rm sample4
git add sample4
git commit -m"sample4 deleted"
if [ "$WITH_SUBMODULE" = "true" ]; then
SUB_NAME="submodule_for_performance_testing"
if [ ! -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
fi
git submodule add ../submodule_for_performance_testing
git commit -am "adding $SUB_NAME module"
fi
cd ..
fi
cd ../..
pwd