-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdnjs.fetch.sh
executable file
·37 lines (28 loc) · 1.2 KB
/
cdnjs.fetch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
. /ColorEcho.sh
set -e
echoCyan "CDNJS repo objects fetch process, no git clone or checkout here!"
git --version
err() {
echoRed >&2 '\n==========ERROR==========\n'
echo >&2 "$@"
echoRed >&2 '\n==========ERROR==========\n'
exit 1
}
if [ "${CI}" != "drone" ] && [ "${DRONE}" != "true" ]; then err "Not a Drone CI environment"; fi
if [ ! -d ".git" ]; then err "Cache .git directory not found!!! What's going on?"; fi
if [ -n "${DRONE_PULL_REQUEST}" ]; then DRONE_COMMIT_BRANCH="pull/${DRONE_PULL_REQUEST}/head"; fi
if echo "${DRONE_REPO_LINK}" | grep 'github.com' > /dev/null 2>&1; then
rm .git/info/sparse-checkout
wget "$(echo "${DRONE_REPO_LINK}" | sed 's/github.com/raw.githubusercontent.com/g')/${DRONE_COMMIT_SHA}/${PLUGIN_SPARSECHECKOUT}" -O ".git/info/sparse-checkout" &
else
err "When does CDNJS drop GitHub? No idea!"
fi
if git remote | grep pre-fetch > /dev/null 2>&1; then
git fetch pre-fetch "${DRONE_REPO_BRANCH}":"${DRONE_REPO_BRANCH}" -f > /dev/null 2>&1 || {
git fetch origin "${DRONE_REPO_BRANCH}":"${DRONE_REPO_BRANCH}" -f
}
else
git fetch origin "${DRONE_REPO_BRANCH}":"${DRONE_REPO_BRANCH}" -f
fi
git fetch origin "${DRONE_COMMIT_BRANCH}"