git update modifié
This commit is contained in:
parent
f0f9fbf3b3
commit
a09a3c1e72
@ -16,8 +16,8 @@ declare -A varia
|
||||
summary="$0 [options] <repo>"
|
||||
|
||||
usage[r]="Reference of wanted commit"
|
||||
varia[r]=reference
|
||||
reference=main
|
||||
varia[r]=ref
|
||||
ref=main
|
||||
|
||||
usage[d]="Destination of clone"
|
||||
varia[d]=dst
|
||||
@ -75,19 +75,16 @@ if [ -d .git ] ; then
|
||||
if [ -n "$tag" ] ; then
|
||||
tagref="tags/$tag"
|
||||
fi
|
||||
|
||||
run git fetch origin "$branch" --tags
|
||||
run git checkout --force $tagref -B "$branch" #merge in ref
|
||||
#run git reset --hard # TODO we can keep some files?
|
||||
run git submodule update --init --recursive --force --depth=1 --remote
|
||||
run git fetch --tags --depth=1 --prune --prune-tags origin $ref
|
||||
run git reset --hard FETCH_HEAD
|
||||
git reflog expire --expire=now --all
|
||||
git gc --aggressive --prune=now
|
||||
# Preserve existing files in some cases
|
||||
if ! "$nonempty_target" ; then
|
||||
if ! "$nonempty_target" ; then #so we keep uncommitted files when not in -N
|
||||
git clean -qffdx
|
||||
fi
|
||||
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
|
||||
run git submodule foreach git clean -fdx
|
||||
|
||||
else
|
||||
clone_dst='.'
|
||||
|
||||
@ -95,8 +92,7 @@ else
|
||||
if "$nonempty_target" ; then
|
||||
clone_dst="$(mktemp -d)"
|
||||
fi
|
||||
|
||||
run git clone -b "$branch" --single-branch --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="$ssh_opt" "$repo" "$clone_dst"
|
||||
run git clone -b "$ref" --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="$ssh_opt" "$repo" "$clone_dst"
|
||||
|
||||
# To override an existing dir, we then move everything to that dir
|
||||
if "$nonempty_target" ; then
|
||||
|
@ -34,7 +34,7 @@ DESCRIPTION
|
||||
TEST0: git cloned in an empty directory
|
||||
TEST1: git cloned in an empty directory with tag
|
||||
TEST2: git cloned in an empty directory with branch
|
||||
|
||||
TEST3: git cloned in an existing directory
|
||||
"
|
||||
}
|
||||
|
||||
@ -117,9 +117,9 @@ test0 (){
|
||||
history_check $REPO_NAME
|
||||
case0=$(($history_result+$cloning_result))
|
||||
if [ "$case0" = "0" ]; then
|
||||
echo "case 0, in a empty directory without history: OK"
|
||||
echo "case 0, in a empty directory: OK"
|
||||
else
|
||||
echo "case 0, in a empty directory without history: FAIL"
|
||||
echo "case 0, in a empty directory: FAIL"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -138,9 +138,9 @@ test1(){
|
||||
|
||||
case1=$(($cloning_result+$history_result+$tag_result))
|
||||
if [ $case1 = 0 ]; then
|
||||
echo "case 1, in a empty directory without history, with tag: OK"
|
||||
echo "case 1, in a empty directory, with tag: OK"
|
||||
else
|
||||
echo "case 1, in a empty directory without history, with tag: FAIL"
|
||||
echo "case 1, in a empty directory, with tag: FAIL"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -159,9 +159,9 @@ test2(){
|
||||
|
||||
case2=$(($cloning_result+$history_result+$branch_result))
|
||||
if [ $case2 = 0 ]; then
|
||||
echo "case 2, in a empty directory without history, with branch: OK"
|
||||
echo "case 2, in a empty directory, with branch: OK"
|
||||
else
|
||||
echo "case 2, in a empty directory without history, with branch: FAIL"
|
||||
echo "case 2, in a empty directory, with branch: FAIL"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -202,13 +202,23 @@ test3(){
|
||||
cd ..
|
||||
case3=$(($cloning_result+$history_result+$existing_result))
|
||||
if [ $case3 = 0 ]; then
|
||||
echo "case 3, in a non-empty directory without history: OK"
|
||||
echo "case 3, in a non-empty directory : OK"
|
||||
else
|
||||
echo "case 3, in a non-empty directory without history: FAIL"
|
||||
echo "case 3, in a non-empty directory : FAIL"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
TEST4(){
|
||||
#CASE 4: git updated ff
|
||||
section TEST4
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while getopts ":hn:a" option; do
|
||||
case $option in
|
||||
|
@ -23,7 +23,7 @@ Comment minimiser la consommation en ressources mémoire et flux de données d'u
|
||||
# Résultats finaux
|
||||
La combinaison finale retenue est :
|
||||
## Pour cloner :
|
||||
git clone --depth=1 --recurse-submodules --remote-submodules --shallow-submodules
|
||||
git clone --depth=1 --recurse-submodules --remote-submodules
|
||||
|
||||
depth=1 permet d'uniquement cloner le dernier commit et les objets nécessaires. Par défaut, elle est single-branch.
|
||||
recurse-submodules s'assure que le contenu des submodules est cloné
|
||||
@ -33,7 +33,7 @@ git clone --depth=1 --recurse-submodules --remote-submodules --shallow-submodul
|
||||
|
||||
## Pour mettre à jour :
|
||||
git submodule update --init --recursive --force --depth=1 --remote
|
||||
git fetch --progress --tags --depth=1 --prune --prune-tags origin
|
||||
git fetch --tags --depth=1 --prune --prune-tags origin
|
||||
git reset --hard origin/main
|
||||
git reflog expire --expire=now --all
|
||||
git gc --aggressive --prune=now
|
||||
|
Loading…
Reference in New Issue
Block a user