avancement sur test_git_update.sh

This commit is contained in:
eleonore12345 2024-07-11 18:31:19 +02:00
parent 0d9b713763
commit 15d3ceb7f0
3 changed files with 45 additions and 30 deletions

View File

@ -4,18 +4,20 @@
# Télécharger un minimum de données # Télécharger un minimum de données
# En cas de conflit donner raison au remote (on écrase les versions locales) # En cas de conflit donner raison au remote (on écrase les versions locales)
#bien que le minimum
#bon tag, bonne branche
#historique bien viré
#si le tag change, c'est bon
declare -A usage declare -A usage
declare -A varia declare -A varia
summary="$0 [options] <repo>" summary="$0 [options] <repo>"
usage[b]="Branch of git repo" usage[r]="Reference of wanted commit"
varia[b]=branch varia[r]=reference
branch=main reference=main
usage[t]="Tag of git repo"
varia[t]=tag
tag=
usage[d]="Destination of clone" usage[d]="Destination of clone"
varia[d]=dst varia[d]=dst
@ -75,13 +77,13 @@ if [ -d .git ] ; then
fi fi
run git fetch origin "$branch" --tags run git fetch origin "$branch" --tags
run git checkout --force $tagref -B "$branch" run git checkout --force $tagref -B "$branch" #merge in ref
run git reset --hard # TODO we can keep some files? #run git reset --hard # TODO we can keep some files?
# Preserve existing files in some cases # Preserve existing files in some cases
if ! "$nonempty_target" ; then if ! "$nonempty_target" ; then
git clean -qffdx git clean -qffdx
fi fi
run git submodule update --init --recursive --force --recommend-shallow run git module update --init --recursive --force --recommend-shallow
run git submodule foreach git fetch run git submodule foreach git fetch
run git submodule foreach git checkout --force HEAD run git submodule foreach git checkout --force HEAD
run git submodule foreach git reset --hard run git submodule foreach git reset --hard

0
readme Normal file
View File

View File

@ -4,10 +4,10 @@
echo "<execution of test_git_update.sh>" echo "<execution of test_git_update.sh>"
REPO_NAME=performance_testing REPO_NAME=performance_testing
REMOTE_LOCATION=./remote REMOTE=ssh://git@git.jean-cloud.net:22529/eleonore/performance_testing.git
WITH_SUBMODULE="true" WITH_SUBMODULE="true"
REMOTE="./remote/performance_testing"
FILENAMES=("sample0" "sample1") FILENAMES=("sample0" "sample1")
FILENAMES_TAG=("sample0")
TAG_NAME=start TAG_NAME=start
if [ "$WITH_SUBMODULE" = "true" ]; then if [ "$WITH_SUBMODULE" = "true" ]; then
@ -34,17 +34,18 @@ cloning_check(){
if [ -d "./$REPO_NAME" ]; then if [ -d "./$REPO_NAME" ]; then
echo "$REPO_NAME has been created" echo "$REPO_NAME has been created"
cloning_result=0 cloning_result=0
cd ./$REPO_NAME local FILENAMES=("$@")
for FILE in ${FILENAMES[@]} echo "--$1--"
echo "------------ $FILENAMES -----------------"
for FILE in "${FILENAMES[@]}"
do do
if [ -f "./$REPO_NAME/$FILE" ]; then if [ -f "./$REPO_NAME/$FILE" ]; then
echo "the file $FILE was correctly imported" echo "the file $FILE has correctly been imported"
else else
cloning_result=1
echo "the file $FILE could not be imported" echo "the file $FILE could not be imported"
cloning_result=1
fi fi
done done
cd ..
else else
cloning_result=1 cloning_result=1
echo "the folder $REPO_NAME could not be created" echo "the folder $REPO_NAME could not be created"
@ -66,6 +67,17 @@ history_check(){
cd .. cd ..
} }
tag_check(){
run cd $REPO_NAME
run git branch > res
if [ $(grep "no branch" res | wc -l) = 1 ];then
tag_result=0
else
tag_result=1
fi
cd ..
}
test0 (){ test0 (){
#CASE 0: git cloned in an empty directory without tag #CASE 0: git cloned in an empty directory without tag
section TEST0 section TEST0
@ -73,15 +85,16 @@ test0 (){
if [ -d $REPO_NAME ]; then if [ -d $REPO_NAME ]; then
rm -rf $REPO_NAME rm -rf $REPO_NAME
fi fi
run ./git_update.sh $REMOTE run ./git_update.sh -d $REPO_NAME $REMOTE
#checks #checks
cloning_check cloning_check "${FILENAMES[@]}"
history_check history_check
case0=$(($history_result+$cloning_result)) case0=$history_result+$cloning_result
if [ $case0=0 ]; then echo "case0 $case0"
echo "case de test 0, dans un dossier vide préexistant, sans historique, sans tag : OK" if [ "$case0" = "0" ]; then
echo "case 0, in a empty directory without history, without tag : OK"
else else
echo "case de test 0, dans un dossier vide préexistant, sans historique, sans tag : ECHEC" echo "case 0, in a empty directory without history, without tag : FAIL"
fi fi
} }
@ -92,17 +105,17 @@ test1(){
if [ -d $REPO_NAME ]; then if [ -d $REPO_NAME ]; then
run rm -rf $REPO_NAME run rm -rf $REPO_NAME
fi fi
run ./git_update.sh -r $TAG_NAME $REMOTE run ./git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE
#checks #checks
cloning_check cloning_check $FILENAMES_TAG
history_check history_check
tagcheck #à ecrire tag_check
case1= case1=$cloning_result+$history_result+$tag_result
if [ "$case1" = "true" ]; then if [ $case1 = 0 ]; then
echo "case de test 1, dans un dossier vide préexistant, sans historique, avec tag : OK" echo "case 0, in a empty directory without history, with tag : OK"
else else
echo "case de test 1, dans un dossier vide préexistant, sans historique, avec tag: ECHEC" echo "case 0, in a empty directory without history, with tag : FAIL"
fi fi
} }