tags:

views:

40

answers:

3

I'm looking to use gitpython to get data on a tree.. to list when the file was commit and the log given.. as far as I have gotten is

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

That just lists things like

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

I don't see anywhere in the git.Blog docs that you can get this data.. am I barking up the wrong tree?

A: 

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

I've never used this API before, though, so I could be off a bit.

Dustin
I don't need the contents.. i need the git log.. like author and log message for the file based on the commit
Mike
A: 

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

repo.heads[0].commit.message

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

J-16 SDiZ
A: 

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
Mike