libgit2/pygit2

Unable to push

KINFOO opened this issue · 7 comments

Hi,

I am using pygit2==0.21.4. I try to push using KeypairFromAgent and I am having a Traceback. Here is my code:

from pygit2 import KeypairFromAgent, Repository

repository = Repository( '/home/kevin/.bee/repositories/bee_test_repository' )
signature = repository.default_signature
credentials = KeypairFromAgent('git')

for remote in repository.remotes:
    remote.credentials = credentials
    remote.push_url = remote.url
    print ('push url: {}'.format(remote.push_url) )
    remote.push('refs/heads/i18n', signature, 'Pushed!')

Here comes the Traceback:

$ python /tmp/sshkeypairfromagent.py
push url: ssh://git@stash.sierrawireless.local:7999/avtools/bee_test_repository.git
Traceback (most recent call last):
  File "/tmp/sshkeypairfromagent.py", line 11, in <module>
    remote.push('refs/heads/i18n', signature, 'Pushed!')
  File "/home/kevin/.virtualenvs/bee/lib/python3.4/site-packages/pygit2/remote.py", line 358, in push
    check_error(err)
  File "/home/kevin/.virtualenvs/bee/lib/python3.4/site-packages/pygit2/errors.py", line 56, in check_error
    raise GitError(message)
_pygit2.GitError: This transport isn't implemented. Sorry

I have read bugs #424 and #379 and tests. I still do not get what I am doing wrong. Any clue?

Kevin

You need to have the development files for libssh2 are available when building libgit2, or it won't be able to connect via ssh.

So, I was doing wrong, thanks Carlos.

I read it somewhere in the docs but unfortunately assumed that I had libssh2 development files installed...

Do you think it woth adding a trouble shooting_ section in push docs. I could provide a pull request for it.

Thanks a lot

I am using default_signature to push in the following:

#!/bin/env python
from pygit2 import KeypairFromAgent, Repository

repository = Repository('/home/kevin/.bee/repositories/bee_test_repository')
remote = repository.remotes[0]
remote.credentials = KeypairFromAgent('git')
remote.push_url = remote.url
print('Signature type: {}'.format(repository.default_signature))
print('Push url: {}'.format(remote.push_url))
remote.push('refs/heads/i18n', repository.default_signature, 'Hourray')

But default_signature does not seem to suffice:

$ python /tmp/push.py
Signature type: <_pygit2.Signature object at 0x7f1e1ccd43f0>
Push url: ssh://git@stash.sierrawireless.local:7999/avtools/bee_test_repository.git
Traceback (most recent call last):
  File "/tmp/push.py", line 10, in <module>
    remote.push('refs/heads/i18n', repository.default_signature, 'Hourray')
  File "/home/kevin/.virtualenvs/bee/lib/python3.4/site-packages/pygit2/remote.py", line 378, 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

Am I (again) missing something out?

Kevin

Regarding the documentation, I would document it in the requirements section of the install page, see http://www.pygit2.org/install.html#requirements

A PR would be very much appreciated.

If you're going to use the default signature, you might as well pass None which should also help work around the type mismatch.

@carlosmn Works like a charm.

I will use this issue for installation documentation PR.

Thanks for the awesome work.
Kevin

Tell me if the previous suffice.

I tried to find which version of libss2 is compliant with libgit2 but could not get this information form its CMakeLists.

I am available for any PR improvement.

Kevin