rosie-ci.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:rosie-ci 作者: adafruit 项目源码 文件源码
def load_code(repo, ref):
    print("loading code from " + repo)
    os.chdir(cwd)

    # Look up our original repo so that we only load objects once.
    base_repo = redis.get("source:" + repo)
    if base_repo is None:
        r = requests.get("https://api.github.com/repos/" + repo,
                         auth=(config["overall"]["github-username"], github_personal_access_token))
        r = r.json()
        base_repo = "source"
        if "source" in r:
            base_repo = r["source"]["full_name"]
        redis.set("source:" + repo, base_repo)
    if base_repo is "source":
        base_repo = repo
    if type(base_repo) is bytes:
        base_repo = base_repo.decode("utf-8")

    print("Source repo of " + repo + " is " + base_repo)

    repo_path = "repos/" + base_repo
    github_base_url = "https://github.com/" + base_repo + ".git"
    github_head_url = "https://github.com/" + repo + ".git"
    print("waiting for repo lock")
    with redis.lock(base_repo, timeout=5*60, blocking_timeout=20*60):
        if not os.path.isdir(repo_path):
            os.makedirs(repo_path)
            git.clone(github_base_url, repo_path)

            # We must make .tmp after cloning because cloning will fail when the
            # directory isn't empty.
            os.makedirs(repo_path + "/.tmp")
        os.chdir(repo_path)
        git.fetch(github_head_url, ref)
    print("loaded", repo, ref)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号