pythongitdulwich

Dulwich: How to automatically stage modified files


In git command line, we can use git commit -a.

How can I do that using dulwich?


Solution

  • When considering the various tests for a commit, like those in test_repository.py, it doesn't seem to be possible in one line:

        r.stage(['a'])
        commit_sha = r.do_commit('modified a',
                                 committer='Test Committer <test@nodomain.com>',
                                 author='Test Author <test@nodomain.com>',
                                 commit_timestamp=12395, commit_timezone=0,
                                 author_timestamp=12395, author_timezone=0)
    

    You need to find modified or deleted files first, and stage them, before calling the commit.

    The other alternative would be to use git-python, which is a wrapper to git, but it doesn't offer either that feature out of the box.