git 批量克隆工程

from urllib.request import urlopen

import json

import subprocess, shlex

 

allProjects     = urlopen("https://{your gitlib host}/api/v4/groups/{you group name}/projects?private_token={your git private token}&per_page=100000")

allProjectsDict = json.loads(allProjects.read().decode())

for thisProject in allProjectsDict: 

    try:

        thisProjectURL  = thisProject['http_url_to_repo']

        # ssh 使用  thisProjectURL  = thisProject['ssh_url_to_repo']

        command     = shlex.split('git clone %s' % thisProjectURL)

        resultCode  = subprocess.Popen(command)

 

    except Exception as e:

        print("Error on %s: %s" % (thisProjectURL, e.strerror))

 

 

 

#新建python执行文件 gitBatchClone.py   内容为上述内容

#使用 python3 ./gitBatchClone.py运行

posted @ 2022-10-08 16:30  zhanghengscnc  阅读(154)  评论(0编辑  收藏  举报