★ wanayoo — archive 1999 https://github.com/libgit2/pygit2/pull/398Nouvelle recherche | Portail wanayoo
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

Improve ability to automatically compile documentation on more architectures and configurations. #398

Merged
merged 3 commits into from Aug 20, 2014

Conversation

@djmattyg007
Copy link
Contributor

djmattyg007 commented Aug 10, 2014

I've spent almost an hour trying to find out what format I should pass the public and private keys in as when using the Keypair class. To me, I would just pass in the path to my private and public keys like so:

myauth = pygit2.Keypair("myusername", "/home/matthew/.ssh/id_rsa.pub", "/home/matthew/.ssh/id_rsa", "mypassword")
repo = pygit2.clone_repository(url="ssh://git@github.com/djmattyg007/modman", path="/tmp/modman", credentials=myauth)

Unfortunately, when I try and run that code, I get this error:

_pygit2.GitError: Failed to authenticate SSH session: Username/PublicKey combination invalid

Am I supposed to read the keys into memory myself from those files and pass those to the Keypair constructor? Am I just getting the username wrong? I can't tell, and the documentation doesn't give any information about this.

@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 4, 2014

After a lot of trial and error, I discovered that the username passed to the Keypair constructor must match the username used in the SSH URL, rather than whatever username was used to create the public key.

I strongly suggest the documentation is updated to indicate that, and to indicate that it is indeed paths to the keyfiles that must be passed.

@carlosmn
Copy link
Member

carlosmn commented Aug 4, 2014

I discovered that the username passed to the Keypair constructor must match the username used in the SSH URL

The username specified in the URL is a hint for the credentials callback (which it could use to prefill a user prompt). What we use is only ever the username that you provide in the KeyPair instance you return to pygit2.

rather than whatever username was used to create the public key.

There is no such concept for SSH keys. The keys are associated to a particular user by the server following its own rules.

The username when using ssh to perform Git operations against GitHub and many other hosters is git, which is what you tell git (the tool) to use by specifying it in the URL. What happens here is exactly the same.

@carlosmn
Copy link
Member

carlosmn commented Aug 4, 2014

There is bound to be some improvements/clarifications we can make to the documentation to say more explicitly that we use whatever is passed, as it's written from the point of someone who knows how the library behaves. But I don't think this is the case for hoster-specific hints.

@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 5, 2014

I've tried making some changes to the docblocks within the code and running 'make html' to view the changes locally. However, none of the changes I'm making seem to take any effect. I'm obviously missing something; I get the feeling that sphinx is looking at the version installed with my package manager rather than the copy I have checked out locally (and am running the commands within). Are you able to point me in the right direction?

@carlosmn
Copy link
Member

carlosmn commented Aug 5, 2014

Because pygit2 is partly in C, it involves two steps, and sphinx looks at where that gets built. You need to run python ./setup.py build for the files to get copied to the right location.

@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 5, 2014

I'm a newcomer to writing documentation in sphinx, so please excuse my ignorance, but shouldn't that be documented somewhere?

What exactly will the result of running 'setup.py build' be? What files will be copied where? Will it affect the version of pygit2 installed with my package manager?

@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 5, 2014

Also, why am I able to compile the documentation successfully if I haven't run that command?

@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 6, 2014

Yeah, whatever it is that's compiling the documentation is looking in /usr/lib/python3.4/site-packages/pygit2 rather than my working copy of the code. How can I stop this from happening?

@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 6, 2014

Upon even further inspection, it would appear that the sphinx conf.py file assumes 64-bit python2.7 has been used to run python setup.py build.

djmattyg007 added 2 commits Aug 10, 2014
…inx docs

This almost certainly isn't perfect, but it's a big step up and should
work on (at least) any 32-bit or 64-bit version of python2 or python3
running on Linux (rather than just 64-bit python2.7 on Linux).
Includes a couple of small grammar fixes to other docstrings.
@djmattyg007 djmattyg007 changed the title Format of public key and private key for the Keypair class Improve ability to automatically compile documentation on more architectures and configurations. Aug 10, 2014
@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 10, 2014

I've converted this to a pull request, and have updated the subject of the issue to match. The pull request aims to make it easier to compile the documentation automatically without needing to alter the sphinx conf.py file. It also updates some documentation relevant to issues discussed previously in this thread with the hope of making it easier to understand.

@@ -61,6 +61,11 @@ class Keypair(object):
This is an object suitable for passing to a remote's credentials
callback and for returning from said callback.
:param str username: the username used in the remote URL

This comment has been minimized.

@carlosmn

carlosmn Aug 10, 2014

Member

Again, this has nothing to do with the username the user may have passed as a hint. This username is the only one that counts, and it has to be the username as which you wish to authenticate to the ssh host.

@djmattyg007
Copy link
Contributor Author

djmattyg007 commented Aug 11, 2014

I've pushed another commit that hopefully clarifies the point in your previous message.

@jdavid jdavid merged commit d752e85 into libgit2:master Aug 20, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@djmattyg007 djmattyg007 deleted the djmattyg007:doc_updates branch Aug 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.