avec https et plus de driglibash
This commit is contained in:
parent
691a715297
commit
f16c64204e
@ -47,7 +47,7 @@ if [ ! -d $REPO_PATH ]; then
|
|||||||
fi
|
fi
|
||||||
cd $REPO_PATH
|
cd $REPO_PATH
|
||||||
if [ ! -d $REPO_NAME ]; then
|
if [ ! -d $REPO_NAME ]; then
|
||||||
echo "remote/performance testing va devoir être créé"
|
echo "remote/performance testing will be created"
|
||||||
mkdir $REPO_NAME
|
mkdir $REPO_NAME
|
||||||
cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
git init
|
git init
|
||||||
|
@ -1,64 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Clone un dépôt git au bon endroit
|
|
||||||
# Stocker un minimum de données (et donc nettoyer)
|
|
||||||
# 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>"
|
summary="$0 [options] <repo>"
|
||||||
|
|
||||||
usage[r]="Reference of wanted commit"
|
|
||||||
varia[r]=ref
|
|
||||||
ref=main
|
ref=main
|
||||||
|
|
||||||
usage[d]="Destination of clone"
|
|
||||||
varia[d]=dst
|
|
||||||
dst='.'
|
dst='.'
|
||||||
|
|
||||||
usage[i]="privkey used to ssh pull"
|
|
||||||
varia[i]=privkey
|
|
||||||
privkey=''
|
|
||||||
|
|
||||||
usage[N]="Clone to a Non-empty target. Existing files will be overwritten"
|
|
||||||
varia[N]=nonempty_target
|
|
||||||
nonempty_target=false
|
nonempty_target=false
|
||||||
|
|
||||||
usage[K]="Remote host key file (known_hosts) for ssh connections"
|
|
||||||
varia[K]=hostkeyfile
|
|
||||||
hostkeyfile=''
|
|
||||||
|
|
||||||
usage[H]="Use real home dir"
|
|
||||||
varia[H]=use_home
|
|
||||||
use_home=false
|
use_home=false
|
||||||
|
|
||||||
usage[a]="use git clean with the aggressive option"
|
|
||||||
varia[a]=be_aggressive
|
|
||||||
be_aggressive=false
|
be_aggressive=false
|
||||||
|
|
||||||
. driglibash-args
|
while getopts ":hr:d:NHa" option; do
|
||||||
|
case $option in
|
||||||
|
h) # display Help
|
||||||
|
Help
|
||||||
|
exit;;
|
||||||
|
r) # branch or tag wanted
|
||||||
|
ref="$OPTARG";;
|
||||||
|
d) # destination of clone
|
||||||
|
dst="$OPTARG";;
|
||||||
|
N) # clone to a Non-empty target. Existing files will be overwritten
|
||||||
|
nonempty_target="true";;
|
||||||
|
H) # use real home dir
|
||||||
|
use_home="false";;
|
||||||
|
a) # use git clean with the aggressive option
|
||||||
|
be_aggressive="true";;
|
||||||
|
\?) # invalid option
|
||||||
|
echo "Error: Invalid option here"
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
|
||||||
# Some SSH options
|
|
||||||
ssh_opt='ssh'
|
|
||||||
if [ -n "$privkey" ] ; then
|
|
||||||
ssh_opt="$ssh_opt -i $privkey"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$hostkeyfile" ] ; then
|
|
||||||
ssh_opt="$ssh_opt -o 'UserKnownHostsFile $hostkeyfile'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
repo="$1"
|
repo="$1"
|
||||||
if [ -z "$repo" ] ; then
|
if [ -z "$repo" ] ; then
|
||||||
die "$0: Empty repo given\n$summary"
|
exit "$0: Empty repo given\n$summary"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $use_home ] ; then
|
if [ ! $use_home ] ; then
|
||||||
@ -67,20 +41,20 @@ if [ ! $use_home ] ; then
|
|||||||
set +a
|
set +a
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run mkdir -p "$dst"
|
mkdir -p "$dst"
|
||||||
run cd "$dst"
|
cd "$dst"
|
||||||
|
|
||||||
|
|
||||||
if [ -d .git ] ; then
|
if [ -d .git ] ; then
|
||||||
|
|
||||||
run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
|
git submodule update --init --recursive --force --depth=1 --remote
|
||||||
run git fetch --tags --depth=1 --prune --prune-tags origin $ref #&> /dev/null
|
git fetch --tags --depth=1 --prune --prune-tags --force origin $ref
|
||||||
run git reset --hard FETCH_HEAD #&> /dev/null
|
git reset --hard FETCH_HEAD
|
||||||
git reflog expire --expire=now --all &> /dev/null
|
git reflog expire --expire=now --all
|
||||||
if "$be_aggressive" ; then
|
if "$be_aggressive" ; then
|
||||||
git gc --prune=now --aggressive &> /dev/null
|
git gc --prune=now --aggressive
|
||||||
else
|
else
|
||||||
git gc --prune=now &> /dev/null
|
git gc --prune=now
|
||||||
fi
|
fi
|
||||||
# Preserve existing files in some cases
|
# Preserve existing files in some cases
|
||||||
if ! "$nonempty_target" ; then #we keep uncommitted files when in -N mode
|
if ! "$nonempty_target" ; then #we keep uncommitted files when in -N mode
|
||||||
@ -94,12 +68,12 @@ else
|
|||||||
if "$nonempty_target" ; then
|
if "$nonempty_target" ; then
|
||||||
clone_dst="$(mktemp -d)"
|
clone_dst="$(mktemp -d)"
|
||||||
fi
|
fi
|
||||||
run git clone -b "$ref" --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="$ssh_opt" "$repo" "$clone_dst"
|
git clone -b "$ref" --recurse-submodules --shallow-submodules --depth 1 "$repo" "$clone_dst"
|
||||||
|
|
||||||
# To override an existing dir, we then move everything to that dir
|
# To override an existing dir, we then move everything to that dir
|
||||||
if "$nonempty_target" ; then
|
if "$nonempty_target" ; then
|
||||||
run mv "$clone_dst/"{*,.*} .
|
mv "$clone_dst/"{*,.*} .
|
||||||
run rmdir "$clone_dst"
|
rmdir "$clone_dst"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
#importer driglibash
|
#importer driglibash
|
||||||
. driglibash-base
|
|
||||||
echo "<execution of test_git_update.sh>"
|
echo "<execution of test_git_update.sh>"
|
||||||
|
|
||||||
|
#Variables definitions
|
||||||
REPO_NAME="performance_testing"
|
REPO_NAME="performance_testing"
|
||||||
REMOTE="ssh://git@git.jean-cloud.net:22529/eleonore/performance_testing.git"
|
REMOTE="https://git.jean-cloud.net/eleonore/performance_testing.git"
|
||||||
WITH_SUBMODULE="true"
|
WITH_SUBMODULE="true"
|
||||||
FILENAMES=("sample0" "sample1 sample3") #we do not check for all files
|
FILENAMES=("sample0" "sample1 sample3") #we do not check for all files
|
||||||
FILENAMES_TAG=("sample0 sample1 sample4")
|
FILENAMES_TAG=("sample0 sample1 sample4")
|
||||||
@ -22,12 +22,6 @@ TMP_CLONE_DIR="tmp_local_clone"
|
|||||||
TMP_EXISTING_DIR="tmp_existing_dir"
|
TMP_EXISTING_DIR="tmp_existing_dir"
|
||||||
TMP_EXISTING_FILE="tmp_existing_file"
|
TMP_EXISTING_FILE="tmp_existing_file"
|
||||||
|
|
||||||
if [ "$WITH_SUBMODULE" = "true" ]; then
|
|
||||||
bash creation_repo.sh -s &> /dev/null
|
|
||||||
else
|
|
||||||
bash creation_repo.sh &> /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
Help()
|
Help()
|
||||||
{
|
{
|
||||||
echo "
|
echo "
|
||||||
@ -53,6 +47,10 @@ DESCRIPTION
|
|||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#output function
|
||||||
|
section(){
|
||||||
|
echo "------------------------------ $1 ------------------------------"
|
||||||
|
}
|
||||||
#check functions
|
#check functions
|
||||||
cloning_check(){
|
cloning_check(){
|
||||||
local input=("$@")
|
local input=("$@")
|
||||||
@ -108,7 +106,7 @@ tag_check(){
|
|||||||
|
|
||||||
branch_check(){
|
branch_check(){
|
||||||
local repo_name=$1
|
local repo_name=$1
|
||||||
run cd $repo_name
|
cd $repo_name
|
||||||
git branch > res
|
git branch > res
|
||||||
if [ $(grep $BRANCH_NAME res | wc -l) = 1 ];then
|
if [ $(grep $BRANCH_NAME res | wc -l) = 1 ];then
|
||||||
echo "The branch instruction has been respected"
|
echo "The branch instruction has been respected"
|
||||||
@ -121,23 +119,23 @@ branch_check(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
existing_check(){
|
existing_check(){
|
||||||
run cd $TMP_EXISTING_DIR
|
cd $TMP_EXISTING_DIR
|
||||||
if [ -f $TMP_EXISTING_FILE ]; then
|
if [ -f $TMP_EXISTING_FILE ]; then
|
||||||
echo "The preexisting non-conflicting file is still here."
|
echo "The preexisting non-conflicting file is still here."
|
||||||
existing_result=0
|
existing_result=0
|
||||||
run cd ..
|
cd ..
|
||||||
conflict_check $TMP_EXISTING_DIR
|
conflict_check $TMP_EXISTING_DIR
|
||||||
existing_result=conflict_result
|
existing_result=conflict_result
|
||||||
else
|
else
|
||||||
echo "The preexisting non-conflicting file has been deleted."
|
echo "The preexisting non-conflicting file has been deleted."
|
||||||
run cd ..
|
cd ..
|
||||||
existing_result=1
|
existing_result=1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
modification_check(){
|
modification_check(){
|
||||||
local repo_name=$1
|
local repo_name=$1
|
||||||
run cd $repo_name
|
cd $repo_name
|
||||||
if [ -f $FILE_TO_BE_CREATED ]; then
|
if [ -f $FILE_TO_BE_CREATED ]; then
|
||||||
echo "The new file has been imported."
|
echo "The new file has been imported."
|
||||||
modification_result=0
|
modification_result=0
|
||||||
@ -152,12 +150,12 @@ modification_check(){
|
|||||||
else
|
else
|
||||||
echo "$FILE_TO_BE_DELETED has been deleted."
|
echo "$FILE_TO_BE_DELETED has been deleted."
|
||||||
fi
|
fi
|
||||||
run cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
switching_branch_check(){
|
switching_branch_check(){
|
||||||
local repo_name=$1
|
local repo_name=$1
|
||||||
run cd $repo_name
|
cd $repo_name
|
||||||
if [ -f $FILE_ON_BRANCH_ONLY ]; then
|
if [ -f $FILE_ON_BRANCH_ONLY ]; then
|
||||||
echo "The files of the branch $BRANCH_NAME are present."
|
echo "The files of the branch $BRANCH_NAME are present."
|
||||||
branch_switching_result=0
|
branch_switching_result=0
|
||||||
@ -177,7 +175,7 @@ switching_branch_check(){
|
|||||||
|
|
||||||
switching_tag_check(){
|
switching_tag_check(){
|
||||||
local repo_name=$1
|
local repo_name=$1
|
||||||
run cd $repo_name
|
cd $repo_name
|
||||||
if [ -f $FILE_ON_TAG_ONLY ]; then
|
if [ -f $FILE_ON_TAG_ONLY ]; then
|
||||||
echo "The files of the tag $TAG_NAME are present."
|
echo "The files of the tag $TAG_NAME are present."
|
||||||
tag_switching_result=0
|
tag_switching_result=0
|
||||||
@ -192,7 +190,7 @@ switching_tag_check(){
|
|||||||
echo "The files of the tag $TAG_NAME are absent."
|
echo "The files of the tag $TAG_NAME are absent."
|
||||||
tag_switching_result=1
|
tag_switching_result=1
|
||||||
fi
|
fi
|
||||||
run cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
conflict_check(){
|
conflict_check(){
|
||||||
@ -209,10 +207,10 @@ conflict_check(){
|
|||||||
|
|
||||||
#intermediate functions
|
#intermediate functions
|
||||||
make_temporary_existing_dir(){
|
make_temporary_existing_dir(){
|
||||||
run mkdir $TMP_EXISTING_DIR
|
mkdir $TMP_EXISTING_DIR
|
||||||
run cd $TMP_EXISTING_DIR
|
cd $TMP_EXISTING_DIR
|
||||||
run touch $TMP_EXISTING_FILE
|
touch $TMP_EXISTING_FILE
|
||||||
run touch $FILE_TO_BE_MODIFIED
|
touch $FILE_TO_BE_MODIFIED
|
||||||
echo "this should be overwritten" > $FILE_TO_BE_MODIFIED
|
echo "this should be overwritten" > $FILE_TO_BE_MODIFIED
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
@ -220,57 +218,57 @@ make_temporary_existing_dir(){
|
|||||||
make_temporary_clone(){
|
make_temporary_clone(){
|
||||||
mkdir $TMP_CLONE_DIR
|
mkdir $TMP_CLONE_DIR
|
||||||
cd $TMP_CLONE_DIR
|
cd $TMP_CLONE_DIR
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --no-single-branch --config core.sshCommand="ssh" $REMOTE . &> /dev/null
|
git clone --recurse-submodules --shallow-submodules --depth 1 --no-single-branch --config core.sshCommand="ssh" $REMOTE . &> /dev/null
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
modification_remote(){
|
modification_remote(){
|
||||||
run cd $TMP_CLONE_DIR
|
cd $TMP_CLONE_DIR
|
||||||
run touch $FILE_TO_BE_CREATED
|
touch $FILE_TO_BE_CREATED
|
||||||
echo "new text" > $FILE_TO_BE_CREATED
|
echo "new text" > $FILE_TO_BE_CREATED
|
||||||
run rm $FILE_TO_BE_DELETED
|
rm $FILE_TO_BE_DELETED
|
||||||
run git add $FILE_TO_BE_CREATED $FILE_TO_BE_DELETED &> /dev/null
|
git add $FILE_TO_BE_CREATED $FILE_TO_BE_DELETED &> /dev/null
|
||||||
run git commit -m "$FILE_TO_BE_CREATED created and $FILE_TO_BE_DELETED deleted" &> /dev/null
|
git commit -m "$FILE_TO_BE_CREATED created and $FILE_TO_BE_DELETED deleted" &> /dev/null
|
||||||
run git push &> /dev/null
|
git push &> /dev/null
|
||||||
run cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
undo_modification_remote(){
|
undo_modification_remote(){
|
||||||
run cd $TMP_CLONE_DIR
|
cd $TMP_CLONE_DIR
|
||||||
run git revert --no-edit HEAD &> /dev/null
|
git revert --no-edit HEAD &> /dev/null
|
||||||
run git push &> /dev/null
|
git push &> /dev/null
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
modification_local(){
|
modification_local(){
|
||||||
run cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
run touch $FILE_TO_BE_CREATED
|
touch $FILE_TO_BE_CREATED
|
||||||
run echo "different text" > $FILE_TO_BE_CREATED
|
echo "different text" > $FILE_TO_BE_CREATED
|
||||||
run git add $FILE_TO_BE_CREATED &> /dev/null
|
git add $FILE_TO_BE_CREATED &> /dev/null
|
||||||
run git commit -m "$FILE_TO_BE_CREATED added" &> /dev/null
|
git commit -m "$FILE_TO_BE_CREATED added" &> /dev/null
|
||||||
run cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
changing_tag(){
|
changing_tag(){
|
||||||
run cd $TMP_CLONE_DIR
|
cd $TMP_CLONE_DIR
|
||||||
run git checkout $TAG_NAME &> /dev/null
|
git checkout $TAG_NAME &> /dev/null
|
||||||
run git tag -f $TAG_FLAG &> /dev/null #temporary tag flag to be able to put the tag back here after the test
|
git tag -f $TAG_FLAG &> /dev/null #temporary tag flag to be able to put the tag back here after the test
|
||||||
run git push -f origin $TAG_FLAG &> /dev/null
|
git push -f origin $TAG_FLAG &> /dev/null
|
||||||
run git checkout $BRANCH_NAME &> /dev/null
|
git checkout $BRANCH_NAME &> /dev/null
|
||||||
run git tag -f $TAG_NAME &> /dev/null #moving the tag on the branch secondary
|
git tag -f $TAG_NAME &> /dev/null #moving the tag on the branch secondary
|
||||||
run git push -f origin $TAG_NAME &> /dev/null #push the move to the remote
|
git push -f origin $TAG_NAME &> /dev/null #push the move to the remote
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
undo_changing_tag(){
|
undo_changing_tag(){
|
||||||
run cd $TMP_CLONE_DIR
|
cd $TMP_CLONE_DIR
|
||||||
run git checkout $TAG_FLAG &> /dev/null
|
git checkout $TAG_FLAG &> /dev/null
|
||||||
run git tag -f $TAG_NAME &> /dev/null #move locally
|
git tag -f $TAG_NAME &> /dev/null #move locally
|
||||||
run git push -f origin $TAG_NAME &> /dev/null #push the move to the remote
|
git push -f origin $TAG_NAME &> /dev/null #push the move to the remote
|
||||||
run git push --delete origin $TAG_FLAG &> /dev/null #delete remotely
|
git push --delete origin $TAG_FLAG &> /dev/null #delete remotely
|
||||||
run git tag --delete $TAG_FLAG &> /dev/null #delete locally
|
git tag --delete $TAG_FLAG &> /dev/null #delete locally
|
||||||
run cd ..
|
cd ..
|
||||||
run rm -rf $TMP_CLONE_DIR
|
rm -rf $TMP_CLONE_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -281,7 +279,7 @@ 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 -d $REPO_NAME $REMOTE &> /dev/null
|
./git_update.sh -d $REPO_NAME $REMOTE &> /dev/null
|
||||||
#checks
|
#checks
|
||||||
cloning_check $REPO_NAME ${FILENAMES[@]}
|
cloning_check $REPO_NAME ${FILENAMES[@]}
|
||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
@ -298,9 +296,9 @@ test1(){
|
|||||||
section TEST1
|
section TEST1
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
run ./git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE &> /dev/null
|
./git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE &> /dev/null
|
||||||
#checks
|
#checks
|
||||||
cloning_check $REPO_NAME ${FILENAMES_TAG[@]}
|
cloning_check $REPO_NAME ${FILENAMES_TAG[@]}
|
||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
@ -319,9 +317,9 @@ test2(){
|
|||||||
section TEST2
|
section TEST2
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
run ./git_update.sh -d $REPO_NAME -r $BRANCH_NAME $REMOTE &> /dev/null
|
./git_update.sh -d $REPO_NAME -r $BRANCH_NAME $REMOTE &> /dev/null
|
||||||
#checks
|
#checks
|
||||||
cloning_check $REPO_NAME ${FILENAMES_BRANCH[@]} #we do not check for all files, especially not those specific to the branch.
|
cloning_check $REPO_NAME ${FILENAMES_BRANCH[@]} #we do not check for all files, especially not those specific to the branch.
|
||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
@ -340,19 +338,19 @@ test3(){
|
|||||||
section TEST3
|
section TEST3
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
#mimic an existing directory, with two existing file, one with the same name as a to-be-cloned file, and go inside the new dir
|
#mimic an existing directory, with two existing file, one with the same name as a to-be-cloned file, and go inside the new dir
|
||||||
make_temporary_existing_dir
|
make_temporary_existing_dir
|
||||||
#make git_update.sh clone in the existing dir
|
#make git_update.sh clone in the existing dir
|
||||||
run cd $TMP_EXISTING_DIR
|
cd $TMP_EXISTING_DIR
|
||||||
run ../git_update.sh -N $REMOTE &> /dev/null
|
../git_update.sh -N $REMOTE &> /dev/null
|
||||||
run cd ..
|
cd ..
|
||||||
#checks
|
#checks
|
||||||
cloning_check $TMP_EXISTING_DIR ${FILENAMES[@]}
|
cloning_check $TMP_EXISTING_DIR ${FILENAMES[@]}
|
||||||
history_check $TMP_EXISTING_DIR
|
history_check $TMP_EXISTING_DIR
|
||||||
existing_check
|
existing_check
|
||||||
run rm -rf tmp_existing_dir
|
rm -rf tmp_existing_dir
|
||||||
|
|
||||||
case3=$((cloning_result+history_result+existing_result))
|
case3=$((cloning_result+history_result+existing_result))
|
||||||
if [ $case3 = 0 ]; then
|
if [ $case3 = 0 ]; then
|
||||||
@ -368,16 +366,16 @@ test4(){
|
|||||||
section TEST4
|
section TEST4
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
#clone the repo in its last state
|
#clone the repo in its last state
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
#modify the remote from elsewhere
|
#modify the remote from elsewhere
|
||||||
modification_remote
|
modification_remote
|
||||||
#make git_update.sh update the repository
|
#make git_update.sh update the repository
|
||||||
run cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
run ../git_update.sh $REMOTE &> /dev/null
|
../git_update.sh $REMOTE &> /dev/null
|
||||||
run cd ..
|
cd ..
|
||||||
#checks
|
#checks
|
||||||
modification_check $REPO_NAME
|
modification_check $REPO_NAME
|
||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
@ -397,20 +395,20 @@ test5(){
|
|||||||
section TEST5
|
section TEST5
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
#clone the repo in its last state
|
#clone the repo in its last state
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
#modify the local repo
|
#modify the local repo
|
||||||
modification_local
|
modification_local
|
||||||
#modify the remote from elsewhere
|
#modify the remote from elsewhere
|
||||||
modification_remote
|
modification_remote
|
||||||
#make git_update.sh update the local repository
|
#make git_update.sh update the local repository
|
||||||
run cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
run ../git_update.sh $REMOTE &> /dev/null
|
../git_update.sh $REMOTE &> /dev/null
|
||||||
run cd ..
|
cd ..
|
||||||
#checks
|
#checks
|
||||||
run conflict_check $REPO_NAME
|
conflict_check $REPO_NAME
|
||||||
#cleaning
|
#cleaning
|
||||||
undo_modification_remote
|
undo_modification_remote
|
||||||
|
|
||||||
@ -427,10 +425,10 @@ test6(){
|
|||||||
section TEST6
|
section TEST6
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
#clone the repo in its last state
|
#clone the repo in its last state
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
#call git update with another branch
|
#call git update with another branch
|
||||||
cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
../git_update.sh -r $BRANCH_NAME $REMOTE &> /dev/null
|
../git_update.sh -r $BRANCH_NAME $REMOTE &> /dev/null
|
||||||
@ -451,14 +449,14 @@ test7(){
|
|||||||
section TEST7
|
section TEST7
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
#clone the repo in its last state
|
#clone the repo in its last state
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
#call git_update.sh with a tag
|
#call git_update.sh with a tag
|
||||||
cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null
|
../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null
|
||||||
run cd ..
|
cd ..
|
||||||
#checks
|
#checks
|
||||||
switching_tag_check $REPO_NAME
|
switching_tag_check $REPO_NAME
|
||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
@ -475,10 +473,10 @@ test8(){
|
|||||||
section TEST8
|
section TEST8
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
#clone the repo in its last state
|
#clone the repo in its last state
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
#call git_update.sh with a tag
|
#call git_update.sh with a tag
|
||||||
cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null
|
../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null
|
||||||
@ -489,9 +487,9 @@ test8(){
|
|||||||
#change the position of the tag from elsewhere
|
#change the position of the tag from elsewhere
|
||||||
changing_tag
|
changing_tag
|
||||||
#call git_update.sh again to go to the new position of the tag
|
#call git_update.sh again to go to the new position of the tag
|
||||||
run cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null
|
../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null
|
||||||
run cd ..
|
cd ..
|
||||||
#put back the remote in its initial state
|
#put back the remote in its initial state
|
||||||
undo_changing_tag
|
undo_changing_tag
|
||||||
|
|
||||||
@ -508,11 +506,6 @@ test8(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ref changed
|
|
||||||
#updating on a branch/tag
|
|
||||||
#créer une option dans creation_repo pour le relier à un remote
|
|
||||||
#appeler creation tmp dir à l'intérieur
|
|
||||||
|
|
||||||
while getopts ":hn:a" option; do
|
while getopts ":hn:a" option; do
|
||||||
case $option in
|
case $option in
|
||||||
h) # display Help
|
h) # display Help
|
||||||
@ -521,7 +514,7 @@ while getopts ":hn:a" option; do
|
|||||||
n)
|
n)
|
||||||
TEST_NUM=$OPTARG;;
|
TEST_NUM=$OPTARG;;
|
||||||
a)
|
a)
|
||||||
ALL_TESTS=true;;
|
ALL_TESTS="true";;
|
||||||
\?) # Invalid option
|
\?) # Invalid option
|
||||||
echo "Error: Invalid option here"
|
echo "Error: Invalid option here"
|
||||||
exit;;
|
exit;;
|
||||||
@ -566,7 +559,7 @@ elif [ -n "$TEST_NUM" ]; then
|
|||||||
test8;;
|
test8;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Invalid test number"
|
echo "Error: Invalid test number"
|
||||||
die;;
|
exit;;
|
||||||
esac
|
esac
|
||||||
if [[ "$TEST_NUM" = 4 || "$TEST_NUM" = 5 || "$TEST_NUM" = 8 ]]; then
|
if [[ "$TEST_NUM" = 4 || "$TEST_NUM" = 5 || "$TEST_NUM" = 8 ]]; then
|
||||||
rm -rf $TMP_CLONE_DIR
|
rm -rf $TMP_CLONE_DIR
|
||||||
@ -574,4 +567,3 @@ elif [ -n "$TEST_NUM" ]; then
|
|||||||
else
|
else
|
||||||
Help
|
Help
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user