git.py 文件源码

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

项目:sphinxcontrib-versioning 作者: Robpol86 项目源码 文件源码
def get_root(directory):
    """Get root directory of the local git repo from any subdirectory within it.

    :raise GitError: If git command fails (dir not a git repo?).

    :param str directory: Subdirectory in the local repo.

    :return: Root directory of repository.
    :rtype: str
    """
    command = ['git', 'rev-parse', '--show-toplevel']
    try:
        output = run_command(directory, command, env_var=False)
    except CalledProcessError as exc:
        raise GitError('Failed to find local git repository root in {}.'.format(repr(directory)), exc.output)
    if IS_WINDOWS:
        output = output.replace('/', '\\')
    return output.strip()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号