cdnjs_git.py 文件源码

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

项目:ExtensionCrawler 作者: logicalhacking 项目源码 文件源码
def hackish_pull_list_changed_files(git_path):
    """Pull new updates from remote origin (hack, using git binary -
       faster but not as safe as GitPython)."""
    git_repo = git.Repo(git_path)
    logging.info(" HEAD: " + str(git_repo.head.commit))
    logging.info("   is detached: " + str(git_repo.head.is_detached))
    logging.info("   is dirty: " + str(git_repo.is_dirty()))
    if git_repo.head.is_detached:
        raise Exception("Detached head")
    if git_repo.is_dirty():
        raise Exception("Dirty repository")
    del git_repo
    gc.collect()

    files = set()
    git_obj = git.Git(git_path)
    pull_lines = git_obj.pull().splitlines()
    del git_obj
    gc.collect()

    for line in pull_lines:
        match = re.search(r'^ (.+) \| .*$', line)
        if not match is None:
            changed_files = match.group(1).split('=>')
            for changed_file in changed_files:
                files.add(changed_file.strip())
    return list(files)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号