Programmatically `git status` with dulwich -
i'm wondering how can perform equivalent of git status dulwich?
i tried this:
after adding/changing/renaming files , staging them commit, i've tried doing:
from dulwich.repo import repo dulwich.index import changes_from_tree r = repo('my-git-repo') index = r.open_index() changes = index.changes_from_tree(r.object_store, r['head'].tree) outputs following:
>>> list(changes) (('makefile', none), (33188, none), ('9b20...', none)) (('test/readme.txt', 'test/readme.txt'), (33188, 33188), ('484b...', '4f89...')) ((none, 'makefile.mk'), (none, 33188), (none, '9b20...')) ((none, 'test.txt'), (none, 33188), (none, '2a02...')) but output requires further process detect:
- i modified
readme.txt. - i renamed
makefilemakefile.mk. - i added
test.txtrepository.
the functions in dulwich.diff_tree provide nicer interface tree changes... not possible before committing?
you should able use dulwich.diff_tree.tree_changes detect changes between 2 trees.
one of requirements add relevant tree objects object store - can use dulwich.index.commit_index this.
Comments
Post a Comment