From 265fac3ca160bc4840b6a779b0df15984b6c9fb2 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 20 Jun 2022 18:54:11 +0800 Subject: [PATCH] Update download-git.sh, support caching [skip ci] --- docker/download-git.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docker/download-git.sh b/docker/download-git.sh index 87439428..4c91737a 100755 --- a/docker/download-git.sh +++ b/docker/download-git.sh @@ -2,6 +2,19 @@ self_dir=$(cd "$(dirname "$0")";pwd) -test "$3" != "yes" && GITHUB_ADDR="hub.fastgit.xyz" || GITHUB_ADDR="github.com" +test -d "$self_dir/source/cache/" || mkdir -p "$self_dir/source/cache" -git clone https://$GITHUB_ADDR/$1.git --depth=1 $self_dir/source/$2 \ No newline at end of file +test "$3" != "yes" && GITHUB_ADDR="https://gh.api.99988866.xyz/" || GITHUB_ADDR="" + +if [ -d "$self_dir/source/cache/$2" ]; then + echo "Using cache for $2" + cp -r "$self_dir/source/cache/$2" "$self_dir/source/" +else + curl -o $self_dir/source/master.zip "$GITHUB_ADDR""https://github.com/$1/archive/master.zip" && \ + cd $self_dir/source/ && \ + unzip master.zip && \ + mv $2-master/ cache/$2/ && \ + cp -r cache/$2 ./ +fi + +# git clone https://$GITHUB_ADDR/$1.git --depth=1 $self_dir/source/$2