0

Now i'm using git svn for cloning repos, when i want to get all their commits and store whem to the db.

For getting all the commits i use pygit2.Repository but i see that i receive only commits from '/trunk/' branch.

If i use git branch -a in terminal i can see all branches:

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

And when i do git log remotes/origin/test-1 i see result with proper commits.

But when i try to receive all commits from repo using pygit2.Repository i receive commits only from trunk, not from other branches - can you advise me a way to get commits from branches too? Maybe i should not use pygit2 but use some other python module?

using repo.listall_branches(2) i see what pygit2 see this branches:

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

but when i try to do repo.lookup_branch('origin/test-1') or repo.lookup_branch('remote/origin/test-1') i receive None instead of pygit2.Branch objects

and when i do

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

i receive only commits from trunk. Please, tell me a proper way to receive all commits from all branches not only commits from trunk.

Vova
  • 580
  • 3
  • 7
  • 20

1 Answers1

1

According to its documentation at http://www.pygit2.org/references.html#branches, repo.branches should give you all branches, local and remote ones.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • I use previous version of pygit2 it doesn't have repo.branches yet. But i figure out how to get all commits: you need to pass branch_type like this - using this code i receive all needed commits heads head = repo.lookup_branch('origin/test-1', 2).get_object() and when i do repo.walk(head.hex) for all branches – Vova Jun 02 '17 at 14:04