creation_repo.sh peut aussi remplir un repo en ligne avec l'option -l
This commit is contained in:
parent
327a91fb01
commit
691a715297
@ -1,6 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. driglibash-base
|
|
||||||
|
|
||||||
Help()
|
Help()
|
||||||
{
|
{
|
||||||
echo "
|
echo "
|
||||||
@ -9,28 +7,35 @@ NAME
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
creation_repo.sh [-h] [-s]
|
creation_repo.sh [-h] [-s]
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
This script creates a "remote" directory in the current directory, then creates a remote/performance_testing git repository.
|
This script creates a ./remote directory in the current directory, then creates a remote/performance_testing git repository.
|
||||||
This git repository is filled with randomly generated binary files described in the readme.md.
|
This git repository is filled with randomly generated binary files described in the readme.md.
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-h prints the help.
|
-h prints the help.
|
||||||
|
-l [link] adds the linked online repository as remote and pushes changes to it. Must be en empty repository.
|
||||||
-s creates a submodule remote/submodule_for_performance_testing and includes it in remote/performance_testing. "
|
-s creates a submodule remote/submodule_for_performance_testing and includes it in remote/performance_testing. "
|
||||||
}
|
}
|
||||||
|
|
||||||
create_random_file(){
|
create_random_file(){
|
||||||
run dd if=/dev/urandom of=$1 bs=$2 count=1 &> /dev/null
|
dd if=/dev/urandom of=$1 bs=$2 count=1 &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
REPO_NAME=performance_testing
|
REPO_NAME=performance_testing
|
||||||
REPO_PATH=./remote
|
REPO_PATH=./remote
|
||||||
WITH_SUBMODULE="false"
|
WITH_SUBMODULE="false"
|
||||||
SUB_NAME="submodule_for_performance_testing"
|
SUB_NAME="submodule_for_performance_testing"
|
||||||
while getopts ":h:s" option; do
|
WITH_LINK="false"
|
||||||
|
while getopts ":hn:sl:" option; do
|
||||||
case $option in
|
case $option in
|
||||||
h)
|
h)
|
||||||
Help
|
Help
|
||||||
exit;;
|
exit;;
|
||||||
s)
|
n)
|
||||||
|
REPO_NAME=$OPTARG;;
|
||||||
|
s)
|
||||||
WITH_SUBMODULE="true";;
|
WITH_SUBMODULE="true";;
|
||||||
|
l)
|
||||||
|
WITH_LINK="true"
|
||||||
|
LINK=$OPTARG;;
|
||||||
\?)
|
\?)
|
||||||
echo "Error: Invalid option"
|
echo "Error: Invalid option"
|
||||||
exit;;
|
exit;;
|
||||||
@ -50,11 +55,8 @@ if [ ! -d $REPO_NAME ]; then
|
|||||||
create_random_file 'sample0' '1M'
|
create_random_file 'sample0' '1M'
|
||||||
git add .
|
git add .
|
||||||
git commit -m"first 1M sample created"
|
git commit -m"first 1M sample created"
|
||||||
git tag start
|
|
||||||
create_random_file 'sample1' '1M'
|
create_random_file 'sample1' '1M'
|
||||||
touch texte
|
git add sample1
|
||||||
echo "un soleil bleu">texte
|
|
||||||
git add sample1 texte
|
|
||||||
git commit -m"second 1M sample created"
|
git commit -m"second 1M sample created"
|
||||||
git branch secondary
|
git branch secondary
|
||||||
git checkout secondary
|
git checkout secondary
|
||||||
@ -62,12 +64,13 @@ if [ ! -d $REPO_NAME ]; then
|
|||||||
git add sample2
|
git add sample2
|
||||||
git commit -m"first 500K sample created in branch secondary"
|
git commit -m"first 500K sample created in branch secondary"
|
||||||
git checkout main
|
git checkout main
|
||||||
create_random_file 'sample3' '1M'
|
|
||||||
git add sample3
|
|
||||||
git commit -m"third 1M sample created"
|
|
||||||
create_random_file 'sample4' '5M'
|
create_random_file 'sample4' '5M'
|
||||||
git add sample4
|
git add sample4
|
||||||
git commit -m"first 5M sample created"
|
git commit -m"first 5M sample created"
|
||||||
|
git tag tagging_point
|
||||||
|
create_random_file 'sample3' '1M'
|
||||||
|
git add sample3
|
||||||
|
git commit -m"third 1M sample created"
|
||||||
rm sample4
|
rm sample4
|
||||||
git add sample4
|
git add sample4
|
||||||
git commit -m"sample4 deleted"
|
git commit -m"sample4 deleted"
|
||||||
@ -86,7 +89,7 @@ if [ ! -d $REPO_NAME ]; then
|
|||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
else # $REPO_NAME exists
|
else # $REPO_NAME exists
|
||||||
echo "remote/performance testing existe"
|
echo "remote/$REPO_NAME already exists"
|
||||||
if [[ "$WITH_SUBMODULE" = "true" && ! -d $SUB_NAME ]]; then
|
if [[ "$WITH_SUBMODULE" = "true" && ! -d $SUB_NAME ]]; then
|
||||||
mkdir $SUB_NAME
|
mkdir $SUB_NAME
|
||||||
cd $SUB_NAME
|
cd $SUB_NAME
|
||||||
@ -106,10 +109,15 @@ else # $REPO_NAME exists
|
|||||||
rm -rf $SUB_NAME
|
rm -rf $SUB_NAME
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user