diff options
author | Simon Rettberg | 2021-11-12 12:30:54 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-11-12 12:30:54 +0100 |
commit | 5aefc23fc0eec0156570469e96855d1341022247 (patch) | |
tree | d235d9aa580ebd53387a4067e6b7a4acdc7623d7 /core/includes | |
parent | [vmware16] 16.2.1 (diff) | |
download | mltk-5aefc23fc0eec0156570469e96855d1341022247.tar.gz mltk-5aefc23fc0eec0156570469e96855d1341022247.tar.xz mltk-5aefc23fc0eec0156570469e96855d1341022247.zip |
[downloader.inc] autoclone: Retry 3 times
This is ugly and stupid, but our git.openslx.org server sometimes
barfs up "error: garbage at end of loose object" when cloning
via https transport.
Diffstat (limited to 'core/includes')
-rw-r--r-- | core/includes/downloader.inc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/core/includes/downloader.inc b/core/includes/downloader.inc index 51ba7962..fc424aae 100644 --- a/core/includes/downloader.inc +++ b/core/includes/downloader.inc @@ -118,7 +118,7 @@ download_if_empty() { # Second syntax is mostly for git servers that don't accept a non-branch when shallow-cloning autoclone () { [ -z "$REQUIRED_GIT" ] && return 0 - local url branch dst dstdir checkout + local url branch dst dstdir checkout i if [ -n "$1" ]; then dstdir="$1" else @@ -137,14 +137,20 @@ autoclone () { dst="${url##*/}" dst="${dst%.git}" pinfo "Cloning $url to $dst" - if [ -n "$branch" ]; then - git clone --depth 1 -b "$branch" "$url" "$dstdir/$dst" || perror "Could not clone $url branch $branch" - else - git clone "$url" "$dstdir/$dst" || perror "Could not clone $url" - if [ -n "$checkout" ]; then - git -C "$dstdir/$dst" checkout "$checkout" || perror "Could not checkout $checkout from $url" + for i in {1..3} fail; do + [ "$i" = "fail" ] && perror "Could not clone." + if [ -n "$branch" ]; then + git clone --depth 1 -b "$branch" "$url" "$dstdir/$dst" && break + pwarning "[Try $i] Could not clone $url branch $branch" + else + if ! git clone "$url" "$dstdir/$dst"; then + pwarning "[Try $i] Could not clone $url" + elif [ -n "$checkout" ]; then + git -C "$dstdir/$dst" checkout "$checkout" && break + perror "Could not checkout $checkout from $url" + fi fi - fi + done [ -n "$AUTOCLONE_FILE" ] \ && echo "$dst: $( git -C "$dstdir/$dst" rev-parse --abbrev-ref HEAD ) $( git -C "$dstdir/$dst" rev-parse --short HEAD )" \ >> "$AUTOCLONE_FILE" |