使用带有 svn repos 的 pygit2 获取所有 repo 提交

get all repo commits using pygit2 with svn repos

现在我正在使用 git svn 克隆回购协议,当我想获得他们的所有提交并将 whem 存储到数据库时。

我使用 pygit2.Repository 获取所有提交,但我看到我只收到来自“/trunk/”分支的提交。

如果我在终端中使用 git branch -a 我可以看到所有分支:

* master
  remotes/origin/test-1
  remotes/origin/test-1@468
  remotes/origin/trunk

当我这样做时 git log remotes/origin/test-1 我看到了正确提交的结果。

但是当我尝试使用 pygit2.Repository 从 repo 接收所有提交时,我只从主干接收提交,而不是从其他分支接收提交 - 你能告诉我一种从分支获取提交的方法吗?也许我不应该使用 pygit2 而应该使用其他一些 python 模块?

使用 repo.listall_branches(2) 我看到了什么 pygit2 看到这个分支:

['origin/test-1', 'origin/trunk', 'origin/test-1@468']

但是当我尝试做 repo.lookup_branch('origin/test-1')repo.lookup_branch('remote/origin/test-1') 时,我收到 None 而不是 pygit2.Branch 对象

当我这样做时

head = repo.lookup_branch('master').get_object()
for native_commit in repo.walk(head.hex):
    print(i)

我只收到来自 trunk 的提交。 请告诉我一种正确的方法来接收来自所有分支的所有提交,而不仅仅是来自 trunk.

的提交

根据它在 http://www.pygit2.org/references.html#branches 的文档,repo.branches 应该给你所有分支,本地 远程分支。