fichier git_update.sh restauré

This commit is contained in:
eleonore12345 2024-07-01 09:30:05 +02:00
parent 13c308a4f3
commit 6ac77f6fa4

View File

@ -1,61 +1,105 @@
## Testing of differeng cloning methods
Our objective is to find the least-consuming method in terms of memory and bandwidth resources.
We are interested in cloning one specific state of the repository. We are not interested in its history or the possibility to change it from the server where it has been cloned. The first step is done by the script creation_repo.sh which creates an adequate repository to test on. The testing in itself is done by performance_tests.sh.
#!/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)
## Creation of the test repository
The script creation_repo.sh creates a performance_testing repository.
NAME
creation_repo.sh
SYNOPSIS
creation_repo.sh [SSH LINK to en empty remote git repository]
DESCRIPTION
This script is in writing.
It creates a git repository in the current directory, linked to a remote passed as argument. Everything is up-to-date between the remote and the local versions. The data stored is generated randomly in binary.
OPTIONS
-h prints the help.
declare -A usage
declare -A varia
Here is a history of the commits:
### branch main
commit f665df376fa57880b5edfb85b156c7703601980e (tag: start)
sample0 1M created
commit a17812c13a69986c1103e0d06ff0a0b59a3a4a63
sample1 1M created
commit bd9d8e9421c3253abba47b9def480f1b2d595568
sample3 1M created
commit 0e599f3b47bf3200dc6e2734df0c6e655c0d8dde
sample4 5M created
commit effb3cab262e6e1e8242e524e1862b6f77d7ad38
sample4 5M deleted
### branch secondary
commit 643cdbbda81f4c4f26513b9d6ecca3d436e97040
sample0 1M created
commit b4bac1f2a2c1b4ab325751748b9496cccc65b082
sample1 1M created
commit e69695f08e79c160045b3319297597a9d8c9b513
sample2 500K created
summary="$0 [options] <repo>"
Which gives us the latest state:
### branch main
sample0 1M
sample1 1M
sample3 1M
### branch secondary
sample0 1M
sample1 1M
sample2 500K
usage[b]="Branch of git repo"
varia[b]=branch
branch=main
usage[t]="Tag of git repo"
varia[t]=tag
tag=
usage[d]="Destination of clone"
varia[d]=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
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
. driglibash-args
# 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"
if [ -z "$repo" ] ; then
die "$0: Empty repo given\n$summary"
fi
if [ ! $use_home ] ; then
set -a
export HOME=/dev/null
set +a
fi
run mkdir -p "$dst"
run cd "$dst"
if [ -d .git ] ; then
# Compute git branch and tag
tagref=
if [ -n "$tag" ] ; then
tagref="tags/$tag"
fi
run git fetch origin "$branch" --tags
run git checkout --force $tagref -B "$branch"
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 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='.'
# To override an existing dir, we need to clone elsewhere first
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"
# To override an existing dir, we then move everything to that dir
if "$nonempty_target" ; then
run mv "$clone_dst/"{*,.*} .
run rmdir "$clone_dst"
fi
fi
## Testing
The script performance_tests.sh measures memory and bandwidth usage of different git cloning scenarii.
NAME
performance_tests.sh
SYNOPSIS
performance_tests.sh [SSH LINK to en empty remote git repository] [number]
OPTIONS
-a excutes all the tests.
-n [number] executes test [number]
-h prints the help.
DESCRIPTION
This script is in writing. It allows you to measure memory and bandwidth usage for different method of cloning on the remote repository given.
TEST0: classic cloning
TEST1: --single-branch