组织介绍

X-Hero

1. Quick Start


1.1. 设置个人SSH密钥

个人Settings -> SSH keys


1.2. 创建个人access token以便访问GitEE API

个人Settings -> Personal access tokens -> Generate new token


1.3. 针对隶属于X-Hero组织下所有仓库的clone程序

在你想要进行clone的目录下运行该程序,例如:

mkdir x-hero
cd x-hero
./x-hero-cap.sh YOUR-ACCESS-TOKEN

1.3.1. MacOS

程序内容:

#!/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

1.3.2. Ubuntu

程序内容:

#!/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"

1.4. 该程序也可以用于在开发过程中一次性pull所有的repo


成就
0
Star
0
Fork
成员(5)
5323182 troysong 1578984527
路飞
5323303 yurihu 1578984528
橙子
5323800 darkwang1126 1578984539
Dark
埼玉
5330409 nickquy 1598430946
Nick

搜索帮助