git - How to get last commit for specified file with python(dulwich)? -


i need author name , last commit time specified file python. currentrly, i'm trying use dulwich.

there're plenty of apis retrieve objects specific sha like:

repo = repo("myrepo") head = repo.head() object = repo.get_object(head) author = object.author time = object.commit_time 

but, how know recent commit specific file? there way retrieve like:

repo = repo("myrepo") commit = repo.get_commit('a.txt') author = commit.author time = commit.commit_time 

or

repo = repo("myrepo") sha = repo.get_sha_for('a.txt') object = repo.get_object(sha) author = object.author time = object.commit_time 

thank you.

something seems work:

from dulwich import repo, diff_tree  fn = 'a.txt' r = repo.repo('.') prev = none walker = r.get_graph_walker() cset = walker.next() while cset not none:      commit = r.get_object(cset)     if prev none:         prev = commit.tree         cset = walker.next()         continue       res = none     delta = diff_tree.tree_changes(r, prev, commit.tree)     x in diff_tree.tree_changes(r, prev, commit.tree):         if x.new.path == fn:             res = cset             break      if res:         break      prev = commit.tree     cset = walker.next()  print fn, res 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -