dulwich

How to get a list of tags and create new tags with python and dulwich in git?

自古美人都是妖i 提交于 2021-02-07 13:57:23
问题 I am having problems to retrieve the following information of a git repo using python: I would like to get a list of all tags of this repository. I would like to checkout another branch and also create a new branch for staging. I would like to tag a commit with an annotated tag. 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? 回答1: The simplest way to get all tags using Dulwich is: from dulwich.repo

add tag / push tags to remote in Python Dulwich

若如初见. 提交于 2020-03-03 08:50:58
问题 I like the Dulwich project as it provides pure Python interface to interacting with git. It looks pretty low-level though... While I couldn't find reference on how to perform simple tasks. My need's are pretty simple, provide the same as below git CLI commands: git push --tags --force git tag --force git show-ref --tags (provides mapping between tag and the commit it points on) Update: looks like item #3 is answered here: How to get a list of tags and create new tags with python and dulwich

How to get last commit for specified file with python(dulwich)?

久未见 提交于 2020-01-16 07:08:11
问题 I need author name and last commit time for a specified file with python. Currentrly, I'm trying to use dulwich. There're plenty of apis to retrieve objects for a specific SHA like: repo = Repo("myrepo") head = repo.head() object = repo.get_object(head) author = object.author time = object.commit_time But, how do i know the recent commit for the specific file? Is there a way to retrieve it like: repo = Repo("myrepo") commit = repo.get_commit('a.txt') author = commit.author time = commit

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' 来源:

Programmatically `git checkout .` with dulwich

我的未来我决定 提交于 2019-12-18 12:37:04
问题 Having this code from dulwich.objects import Blob, Tree, Commit, parse_timezone from dulwich.repo import Repo from time import time repo = Repo.init("myrepo", mkdir=True) blob = Blob.from_string("my file content\n") tree = Tree() tree.add("spam", 0100644, blob.id) commit = Commit() commit.tree = tree.id author = "Flav <foo@bar.com>" commit.author = commit.committer = author commit.commit_time = commit.author_time = int(time()) tz = parse_timezone('+0200')[0] commit.commit_timezone = commit

Do the git repository data structures use a canonical encoding?

限于喜欢 提交于 2019-12-13 14:59:18
问题 I'm using dulwich (a Python library) to access a git repository. When I use get_object to retrieve a commit, it has a number of attributes. One of those is author . When I retrieve this attribute, I get bytes and so the attribute is an an unknown encoding. Is there an encoding I can safely assume? Does git translate all the metadata to utf-8 before storing it? If it doesn't, how do I know which encoding to use to decode the bytes? 回答1: Metadata is supposed to be encoded with the value set by

How to pull from the remote using dulwich?

风流意气都作罢 提交于 2019-12-07 06:40:07
问题 How to do something like git pull in python dulwich library. 回答1: I haven't used dulwich, but from these doc's, possibly something like: from dulwich.repo import Repo from dulwich.client import HttpGitClient local = Repo.init("local", mkdir=True) client = HttpGitClient('http://github.com/adammorris/') remote_refs = client.fetch("history.js.git",local) local["HEAD"] = remote_refs["refs/heads/master"] At this point, it didn't load the files, but I could do "git checkout" from the local path,

In Dulwich, how do I commit to a branch instead of to HEAD?

十年热恋 提交于 2019-12-06 05:07:44
问题 Apparently repo.do_commit(message='test commit', committer='Name ') only commits to refs/heads/master. Is there a way to set the current commit ref to another one than refs/heads/master? Or is the only way to commit to a branch by creating a Commit object (as shown in the tutorial in the documentation) and setting it's parent to be the one of the branches commit id? Should this be true, which would then be the use of repo.do_commit other than committing to refs/heads/master? 回答1: Creating a

How to pull from the remote using dulwich?

白昼怎懂夜的黑 提交于 2019-12-05 10:57:37
How to do something like git pull in python dulwich library. Adam Morris I haven't used dulwich, but from these doc's , possibly something like: from dulwich.repo import Repo from dulwich.client import HttpGitClient local = Repo.init("local", mkdir=True) client = HttpGitClient('http://github.com/adammorris/') remote_refs = client.fetch("history.js.git",local) local["HEAD"] = remote_refs["refs/heads/master"] At this point, it didn't load the files, but I could do "git checkout" from the local path, and it updated the files. Also, saw these: https://lists.launchpad.net/dulwich-users/msg00118

In Dulwich, how do I commit to a branch instead of to HEAD?

只愿长相守 提交于 2019-12-04 11:14:40
Apparently repo.do_commit(message='test commit', committer='Name ') only commits to refs/heads/master. Is there a way to set the current commit ref to another one than refs/heads/master? Or is the only way to commit to a branch by creating a Commit object (as shown in the tutorial in the documentation) and setting it's parent to be the one of the branches commit id? Should this be true, which would then be the use of repo.do_commit other than committing to refs/heads/master? Creating a Commit object manually and then setting the tag is indeed the only way to commit to a non-HEAD branch in the