pythongitdulwich

How to add something to the index, commit it, then push the master branch to a named remote with dulwich?


How can I add something to the index, as in

git add .

then

git commit -m "message"

then

git push origin master

using dulwich?

So far I've found this http://www.samba.org/~jelmer/dulwich/apidocs/dulwich.index.Index.html but it doesn't say much, does it?

Thanks


Solution

  • This is not a tested answer but it is closer on the push part:

    # set wants to master
    def wantmaster(haves, wants):
      global repo
      return { "refs/heads/master": repo.refs["HEAD"] }
    
    client, src = dulwich.client.get_transport_and_path(origin_uri) 
    
    client.send_pack(src, wantmaster, repo.object_store.generate_pack_contents)
    

    A variation on this is working in my code.