Added script to fetch full clones

Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf
2023-10-17 17:36:42 +02:00
committed by Julius Härtl
parent dae008139b
commit ef21ea6be3
2 changed files with 90 additions and 0 deletions
+4
View File
@@ -258,6 +258,8 @@ case $SERVER_CLONE in
$ git fetch origin
This may take some time depending on your internet connection speed.
You might as well use the script in scripts/download-full-history.sh.
EOF
;;
clone-no-blobs)
@@ -270,6 +272,8 @@ EOF
You should be prepared to have a live internet connection when browsing the
history of the server repository.
You might as well use the script in scripts/download-full-history.sh.
EOF
;;
full)
+86
View File
@@ -0,0 +1,86 @@
#!/bin/bash -e
isShallow() {
# Reference: https://stackoverflow.com/a/37533086
local isShallow
isShallow="$(git rev-parse --is-shallow-repository)"
if [ "$isShallow" = 'true' ]
then
return 0
else
return 1
fi
}
unshallow() {
echo "Unshallowing installation as it is needed"
git fetch --unshallow
}
isPartialClone() {
git config --get "remote.$1.partialclonefilter" &> /dev/null && return 0 || return 1
}
unpartial () {
git config --unset "remote.$1.partialclonefilter"
git fetch --refetch
}
UNSHALLOW=1
UNPARTIAL=1
REPOSITORY=workspace/server
ORIGIN=origin
while [ $# -gt 0 ]
do
case "$1" in
--no-unshallow)
UNSHALLOW=0
;;
--unshallow)
UNSHALLOW=1
;;
--no-unpartial)
UNPARTIAL=0
;;
--unpartial)
UNPARTIAL=1
;;
--repository)
REPOSITORY="$2"
shift
;;
--origin)
ORIGIN="$2"
shift
;;
*)
echo "Unknown parameter '$1' found. Exiting."
exit 1
;;
esac
shift
done
cd "$REPOSITORY"
if [ "$UNSHALLOW" = 1 ]
then
if isShallow
then
unshallow
else
echo 'The repository is already unshallowed'
fi
fi
if [ "$UNPARTIAL" = 1 ]
then
if isPartialClone "$ORIGIN"
then
echo 'Partial clone found'
unpartial "$ORIGIN"
else
echo 'Repository does not contain partial clones'
fi
fi