controller.py 文件源码

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

项目:bibtex_diff_checker 作者: mziauddin 项目源码 文件源码
def create_local_repo(remote_git,dir,branch):
    """ Uses the git.clone_from method to clone a remote git repository locally
        Args:
            remote_git: Url of the remote git repository
            dir: Local directory where the contents of the 
                remote git will be downloaded
            branch: Name of the branch on the remote git which will be used for cloning
        Returns:
            git.repo: Reference to the local git repository
        Raises:
            git.exc.InvalidGitRepositoryError: If remote git repository is bare
            git.exc.GitCommandError: If remote git repository does not exist
    """    

    if(os.path.exists(dir)):
         shutil.rmtree(dir)
    try:
        repo = Repo.clone_from(
                url=remote_git,
                to_path=dir,
                branch=branch            
                )
        if repo.bare:  
            raise git.exc.InvalidGitRepositoryError
        else:
            return repo

    except git.exc.GitCommandError:
        print "Please make sure you have the correct access rights and the repository exists"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号