init.py 文件源码

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

项目:pomu 作者: Hummer12007 项目源码 文件源码
def init_plain_repo(create, repo_path):
    """
    Initialize a plain repository
    Parameters:
        create - if true, create a new git repo,
                 else, reuse an existing one
        repo_path - a path for the repository to reside in
    """
    if not repo_path:
        return Result.Err('repository path required')
    if create:
        if path.isdir(repo_path):
            return Result.Err('this repository already exists')
        try:
            makedirs(repo_path)
        except PermissionError:
            return Result.Err('you do not have enough permissions to create the git repository')
        Repo.init(repo_path)
        try:
            return Result.Ok(init_new(repo_path).unwrap())
        except ResultException as e:
            rmtree(repo_path)
            return Result.Err(str(e))
    else:
        if not path.isdir(repo_path):
            return Result.Err('directory not found')
        return init_pomu(repo_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号