Skip to content

Commit

Permalink
Added script to fetch full clones
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Wolf <[email protected]>
  • Loading branch information
christianlupus committed Dec 5, 2023
1 parent b045f88 commit 853e7f9
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
86 changes: 86 additions & 0 deletions scripts/download-full-history.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 853e7f9

Please sign in to comment.