I am having problems to retrieve the following information of a git repo using python:
I have looked into the dulwich's documentation and the way it works seems very bare-bones. Are there also alternatives which are easier to use?
The simplest way to get all tags using Dulwich is:
from dulwich.repo import Repo
r = Repo("/path/to/repo")
tags = r.refs.as_dict("refs/tags")
tags is now a dictionary mapping tags to commit SHA1s.
Checking out another branch:
r.refs.set_symbolic_ref("HEAD", "refs/heads/foo")
r.reset_index()
Creating a branch:
r.refs["refs/heads/foo"] = head_sha1_of_new_branch
Now you can also get an alphabetically sorted list of tag labels.
from dulwich.repo import Repo
from dulwich.porcelain import tag_list
repo = Repo('.')
tag_labels = tag_list(repo)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With