Update download-git.sh, support caching [skip ci]

This commit is contained in:
Jerry Ma 2022-06-20 18:54:11 +08:00 committed by GitHub
parent 09437d3e91
commit 265fac3ca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
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