简体   繁体   中英

How to get URL of remote in Dulwich

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']

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM