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
# 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 varia
summary="$0 [options] <repo>"
usage[b]="Branch of git repo"
varia[b]=branch
branch=main
usage[t]="Tag of git repo"
varia[t]=tag
tag=
usage[r]="Reference of wanted commit"
varia[r]=reference
reference=main
usage[d]="Destination of clone"
varia[d]=dst
@ -75,13 +77,13 @@ if [ -d .git ] ; then
fi
run git fetch origin "$branch" --tags
run git checkout --force $tagref -B "$branch"
run git reset --hard # TODO we can keep some files?
run git checkout --force $tagref -B "$branch" #merge in ref
#run git reset --hard # TODO we can keep some files?
# Preserve existing files in some cases
if ! "$nonempty_target" ; then
git clean -qffdx
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 checkout --force HEAD
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>"
REPO_NAME=performance_testing
REMOTE_LOCATION=./remote
REMOTE=ssh://git@git.jean-cloud.net:22529/eleonore/performance_testing.git
WITH_SUBMODULE="true"
REMOTE="./remote/performance_testing"
FILENAMES=("sample0" "sample1")
FILENAMES_TAG=("sample0")
TAG_NAME=start
if [ "$WITH_SUBMODULE" = "true" ]; then
@ -34,17 +34,18 @@ cloning_check(){
if [ -d "./$REPO_NAME" ]; then
echo "$REPO_NAME has been created"
cloning_result=0
cd ./$REPO_NAME
for FILE in ${FILENAMES[@]}
local FILENAMES=("$@")
echo "--$1--"
echo "------------ $FILENAMES -----------------"
for FILE in "${FILENAMES[@]}"
do
if [ -f "./$REPO_NAME/$FILE" ]; then
echo "the file $FILE was correctly imported"
echo "the file $FILE has correctly been imported"
else
cloning_result=1
echo "the file $FILE could not be imported"
cloning_result=1
fi
done
cd ..
else
cloning_result=1
echo "the folder $REPO_NAME could not be created"
@ -66,6 +67,17 @@ history_check(){
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 (){
#CASE 0: git cloned in an empty directory without tag
section TEST0
@ -73,15 +85,16 @@ test0 (){
if [ -d $REPO_NAME ]; then
rm -rf $REPO_NAME
fi
run ./git_update.sh $REMOTE
run ./git_update.sh -d $REPO_NAME $REMOTE
#checks
cloning_check
cloning_check "${FILENAMES[@]}"
history_check
case0=$(($history_result+$cloning_result))
if [ $case0=0 ]; then
echo "case de test 0, dans un dossier vide préexistant, sans historique, sans tag : OK"
case0=$history_result+$cloning_result
echo "case0 $case0"
if [ "$case0" = "0" ]; then
echo "case 0, in a empty directory without history, without tag : OK"
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
}
@ -92,17 +105,17 @@ test1(){
if [ -d $REPO_NAME ]; then
run rm -rf $REPO_NAME
fi
run ./git_update.sh -r $TAG_NAME $REMOTE
run ./git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE
#checks
cloning_check
cloning_check $FILENAMES_TAG
history_check
tagcheck #à ecrire
tag_check
case1=
if [ "$case1" = "true" ]; then
echo "case de test 1, dans un dossier vide préexistant, sans historique, avec tag : OK"
case1=$cloning_result+$history_result+$tag_result
if [ $case1 = 0 ]; then
echo "case 0, in a empty directory without history, with tag : OK"
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
}