download-git.sh 640 B

1234567891011121314151617181920
  1. #!/usr/bin/env bash
  2. self_dir=$(cd "$(dirname "$0")";pwd)
  3. test -d "$self_dir/source/cache/" || mkdir -p "$self_dir/source/cache"
  4. test "$3" != "yes" && GITHUB_ADDR="https://gh.api.99988866.xyz/" || GITHUB_ADDR=""
  5. if [ -d "$self_dir/source/cache/$2" ]; then
  6. echo "Using cache for $2"
  7. cp -r "$self_dir/source/cache/$2" "$self_dir/source/"
  8. else
  9. wget -O $self_dir/source/master.zip "$GITHUB_ADDR""https://github.com/$1/archive/master.zip" && \
  10. cd $self_dir/source/ && \
  11. unzip master.zip && \
  12. mv $2-master/ cache/$2 && \
  13. cp -r cache/$2 ./
  14. fi
  15. # git clone https://$GITHUB_ADDR/$1.git --depth=1 $self_dir/source/$2