Search code examples
pythongitgitpython

How to use --force-with-lease with (GitPython) git.remote.Remote?


I am trying to be Pythonic. Thus, I have this code:

import git
import uuid

repo = git.Repo(...)
u = repo.create_remote(uuid.uuid4(), 'https://github.com/...')

If I wasn't trying to be pythonic, I could do this:

repo.git.push(u.name, refspec, '--force-with-lease')

...but I am trying to be Pythonic. How do I do a --force-with-lease push using this (git.remote.Remote) object?

u.push(refspec, help=needed)

It looks like I can say:

u.push(refspec, force=True)

...but I don't think that uses a lease?


Solution

  • After having a quick look at the source code of GitPython, I would guess that it turns _ into - when interpreting the **kwargs. I think the correct way should be:

    u.push(refspec, force_with_lease=True)
    

    Based on: function dashify(), which is called from function transform_kwarg().