2017-06-02 62 views
0

現在我使用git svn克隆回購,當我想要獲取所有提交併將數據存儲到數據庫時。使用pygit2與svn回購獲得所有回購提交

爲了獲得所有提交我使用pygit2.Repository,但我看到我只接收'/ trunk /'分支提交。

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

* master 
    remotes/origin/test-1 
    remotes/origin/[email protected] 
    remotes/origin/trunk 

當我做git log remotes/origin/test-1我看到正確提交結果。

但是,當我嘗試從回購使用pygit2.Repository接收所有提交時,我只收到來自trunk的提交,而不是其他分支 - 你能否告訴我一種從分支獲取提交的方法?也許我不應該使用pygit2,但使用一些其他的Python模塊?

使用repo.listall_branches(2)我看到pygit2看到這個分支:

['origin/test-1', 'origin/trunk', 'origin/[email protected]'] 

但是當我嘗試做repo.lookup_branch('origin/test-1')repo.lookup_branch('remote/origin/test-1')我收到無不是pygit2.Branch對象

,當我做的

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

我只收到trunk的提交。 請告訴我一個正確的方法來接收來自所有分支機構的所有提交,不僅承諾trunk

回答

1

據其在http://www.pygit2.org/references.html#branches文件,repo.branches應該給你的所有分支機構,本地遠程的。

+0

我使用先前版本的pygit2,它還沒有repo.branches。但我弄清楚如何獲得所有提交:你需要像這樣傳遞branch_type - 使用這段代碼我收到所有需要的提交頭head = repo.lookup_branch('origin/test-1',2).get_object()當我爲所有分支做repo.walk(head.hex) – Vova