Search code examples
pythonpython-3.xlibgit2pygit2

An error in signature when pushing using pygi2


I'm facing problem when pushing using pygit2 v0.21.3 . here is my code :

import pygit2 as git
repo = git.Repository("path/to/my/repo.git") # just for testing,it will not be local

for rem in repo.remotes:
    rem.push_url = rem.url
    rem.credentials = git.UserPass("user","passowrd")
    sig = git.Signature("user","[email protected]")

    rem.push('refs/heads/master',signature=sig)
    # in v0.22.0 it will be like below
    # rem.push(['refs/heads/master'],signature=sig)

But,I always received this message :

Traceback (most recent call last):
  File "C:\test.py", line 9, in <module>
    rem.push('refs/heads/master',signature=sig)
  File "C:\Python34\lib\site-packages\pygit2-0.21.3-py3.4-win32.egg\pygit2\remote.py",line 353, in push
    err = C.git_push_update_tips(push, ptr, to_bytes(message))
TypeError: initializer for ctype 'git_signature *' must be a cdata pointer, not bytes

When I tried it with version 0.22.0 it didn't raise an error, but push operation also didn't work.

Note: I think the problem with signature parameter, because when I pass None It works fine with default signature .

Thanks.


Solution

  • I had updated pygit2 to v0.22.1, libgit2 to v0.22.3 , it fixed the problem.