How to get URL of remote in Dulwich

二次信任 提交于 2019-12-24 12:00:33

问题


I want to be able to get a URL like https://github.com/user/repo.git given a remote name such as origin. So far I have only managed to get the commit hash:

>>> from dulwich import porcelain
>>> hash = porcelain.ls_remote('.')[b'refs/remotes/origin/master']

回答1:


At the moment, there is no porcelain wrapper for this. With the plumbing, you can use:

>>> from dulwich.repo import Repo
>>> config = Repo('.').get_config()
>>> config.get(('remote', 'origin'), 'url')
b'git://jelmer.uk/dulwich'


来源:https://stackoverflow.com/questions/58781823/how-to-get-url-of-remote-in-dulwich

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!