Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce credential support #354

Merged
merged 6 commits into from
Mar 27, 2014
Merged

Introduce credential support #354

merged 6 commits into from
Mar 27, 2014

Conversation

carlosmn
Copy link
Member

Implement support for username/password and ssh keypair credentials. Add support for them in the Remote as well as clone_repository(). The parameters expect a callback, but the provided types already provide the right __call__ interface.

There's a bit of sausage-making in this PR, with a bunch of code being removed in the middle, but I've kept it to show the process by which I arrived at this design.

Credentials implement two attributes, and the pygit2 code extracts the information from a tuple and passes it on to libgit2.

It claims you need to checkout a branch after clone, which is not the
case currently (the clone function will do it for you).

While here, format the docstring for sphinx to make it pretty.
The docs say to use tp_free() to free the memory, and even though we use
PyObject_Del() everywhere else, using this in the credentials does cause
issues.
Instead of making everyone inherit from our credential types, use an
interface with two attributes, which makes the C code much shorter and
simpler.
@jdavid jdavid merged commit 82d8819 into libgit2:master Mar 27, 2014
This was referenced Mar 28, 2014
@remusavram
Copy link

I cloned the latest release: pygit-0.23.3

print help(pygit2.clone_repository)

Help on function clone_repository in module pygit2:

clone_repository(url, path, bare=False, repository=None, remote=None, checkout_branch=None, callbacks=None)
    Clones a new Git repository from *url* in the given *path*.

    Returns a Repository class pointing to the newly cloned repository.

I tried:

pygit2.clone_repository(url, path, credentials=cred)

Get:

    pygit2.clone_repository(url, path, credentials=cred)
TypeError: clone_repository() got an unexpected keyword argument 'credentials'

Question:
How can I clone a remote repository using SSH?

@nick-ulle
Copy link

@remusvrm The documentation isn't very clear, but what you need to do is:

callbacks = pygit2.RemoteCallbacks(credentials = cred)
pygit2.clone_repositry(url, path, callbacks = callbacks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants