GitPython gets commit for file

I am looking to use gitpython to retrieve data on a tree .. to indicate when the file was committed and the log provided .. as far as I received,

from git import * repo = get_repo("/path/to/git/repo") for item in repo.tree().items(): print item[1] 

It just lists things like

 <git.Tree "ac1dcd90a3e9e0c0359626f222b99c1df1f11175"> <git.Blob "764192de68e293d2372b2b9cd0c6ef868c682116"> <git.Blob "39fb4ae33f07dee15008341e10d3c37760b48d63"> <git.Tree "c32394851edcff4bf7a452f12cfe010e0ed43739"> <git.Blob "6a8e9935334278e4f38f9ec70f982cdc4f42abf0"> 

I do not see anywhere in the git.Blog docs that you can get this data. Am I barking the wrong tree?

+4
source share
4 answers

Anyone who wants to do this now will be as follows:

The last 100 are sorted in descending order:

repo.iter_commits('master', max_count=100)

You can use skip to swap:

repo.iter_commits('master', max_count=10, skip=20)

Link: http://gitpython.readthedocs.org/en/stable/tutorial.html#the-commit-object

+4
source

After 4 hours, I finally got it

 repo = get_repo("/path/to/git/repo") items = repo.tree().items() items.sort() for i in items: c = repo.commits(path=i[0], max_count=1) print i[0], c[0].author, c[0].authored_date, c[0].message 
+2
source

The commit message is in a commit object , not a tree object . I think you can get it with

 repo.heads[0].commit.message 

(note: I don't know python, this is based on my knowledge of git and a minute on reading api docs)

+1
source

I believe you can use blob.data_stream() to get a file-like object containing raw data content.

I have never used this API before, so I could be a bit.

0
source

All Articles