let's ask me why
个人Settings -> SSH keys
个人Settings -> Personal access tokens -> Generate new token
在你想要进行clone的目录下运行该程序,例如:
mkdir x-hero
cd x-hero
./x-hero-cap.sh YOUR-ACCESS-TOKEN
程序内容:
#!/usr/bin/env bash
url_list=(`curl -X GET --header \
'Content-Type: application/json;charset=UTF-8' \
"https://gitee.com/api/v5/orgs/x-hero/repos?access_token=$1&type=private&page=1&per_page=30" \
| egrep -o "full_name.*?," \
| awk -F '/' '{print $2}' \
| awk -F '\"' '{print $1}'`)
echo '---------------------------------------------------------------------'
for ((i=0;i<${#url_list[@]};i++)); do
echo "[ `expr $i + 1` / ${#url_list[@]} ]"
if [ ! -d ${url_list[i]} ]; then
echo "${url_list[i]} is cloning..."
while true; do
git clone git@gitee.com:x-hero/${url_list[i]}.git && break
done
echo 'clone done'
else
echo "${url_list[i]} is already exist! try to pull..."
if [ ! -d ${url_list[i]}/.git ]; then
echo "pull failed: it's not a git repo!"
else
cd ${url_list[i]}
while true; do
git pull && break
done
cd ..
echo 'pull done'
fi
fi
echo '---------------------------------------------------------------------'
done
程序内容:
#!/usr/bin/env bash
url_list=(`curl -X GET --header \
'Content-Type: application/json;charset=UTF-8' \
"https://gitee.com/api/v5/orgs/x-hero/repos?access_token=$1&type=private&page=1&per_page=30" \
| grep -P -o "full_name.*?," \
| awk -F '/' '{print $2}' \
| awk -F '\"' '{print $1}'`)
# FIXME
num=5
str='#'
max=100
pro=('|' '/' '-' '\')
echo '---------------------------------------------------------------------'
for ((i=0;i<${#url_list[@]}-1;i++)); do
if [ ${url_list[i]} == "trash" ]; then
continue
fi
echo "[ `expr $i + 1` / `expr ${#url_list[@]} - 1` ]"
if [ ! -d ${url_list[i]} ]; then
echo "${url_list[i]} is cloning..."
while true; do
git clone git@gitee.com:x-hero/${url_list[i]}.git && break
done
echo 'clone done'
else
echo "${url_list[i]} is already exist! try to pull..."
if [ ! -d ${url_list[i]}/.git ]; then
echo "pull failed: it's not a git repo!"
else
cd ${url_list[i]}
while true; do
git pull && break
done
cd ..
echo 'pull done'
fi
fi
echo '---------------------------------------------------------------------'
# FIXME
((color=30+num%8))
echo -en "\e[1;"$color"m"
let index=num%4
let num+=5
printf "[%-100s %d%% %c]\r" "$str" "$num" "${pro[$index]}"
sleep 0.02
str+='#####'
done
printf "\n"
echo -e "\e[1;30;m"