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

Add 'sshkey' context manager #242

Merged
merged 6 commits into from
Jan 22, 2015
Merged

Add 'sshkey' context manager #242

merged 6 commits into from
Jan 22, 2015

Conversation

teeberg
Copy link
Contributor

@teeberg teeberg commented Jan 21, 2015

Proposed implementation for #234

I have done some manual tests, but not set up automated tests yet. I will see how it fits into your suite tomorrow if you haven't implemented it yet. :)

Let me know if something's not quite in the right place.

@teeberg teeberg changed the title Add sshkey context manager Add 'sshkey' context manager Jan 21, 2015
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 8fbe7ee on teeberg:master into bb0f3d7 on gitpython-developers:master.

self.set_environment(**old_env)

@contextmanager
def sshkey(self, sshkey_file):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a moment I thought this method is to specific, but on the other hand, it makes setting ssh-keys (by using key-files) really easy.
Therefore the only thing I will do is see how this works on windows, and possibly put in an assertion to run on non-windows systems only.

@Byron
Copy link
Member

Byron commented Jan 21, 2015

Thank you !
It looks very good already, and is more feature-rich than I would have done it, thanks to your personal interest.

@@ -153,3 +153,23 @@ def test_env_vars_passed_to_git(self):
editor = 'non_existant_editor'
with mock.patch.dict('os.environ', {'GIT_EDITOR': editor}):
assert self.git.var("GIT_EDITOR") == editor

def test_environment(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how I could test the sshkey context manager without accessing an actual repo. Also, how could I check whether the environment is actually passed into the git process? The former would cover the latter. Do you have ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that could work is to adjust the script for the test to actually fail with a distinct error code, and possibly emit something distinctive to STDERR.
That way, you could call the real git process, on a bogus git@server:foo/bar repo URL, and verify that it failed under your conditions. That can proof that the script was actually called.
The cool thing is that this would require you to put in a way to adjust the path the script handling the GIT_SSH, which could be done so that advanced users can either set it, or derive from the Git command implementation.

@coveralls
Copy link

Coverage Status

Coverage remained the same at % when pulling 6f03861 on teeberg:master into d565a87 on gitpython-developers:master.

@Byron
Copy link
Member

Byron commented Jan 22, 2015

You did it !
The only minor issue I am still choking on is the with repo.git.with_environment(...) notation of the context manager and the seemingly redundant use of with_ .

Note to self: Test this on windows and at least throw saying sshkey doesn't work, if it doesn't work

Also I believe today will be the day, as I should get through my docs review, and prepare a new release.

@Byron Byron merged commit 6f03861 into gitpython-developers:master Jan 22, 2015
@Byron
Copy link
Member

Byron commented Jan 24, 2015

Before I forget: I had to remove sshkey from the release, as I was unable to tell setup.py to keep that file where it is after installation, AND keep it executable.
I think I even recorded my futile attempt to beat setuptools in all it's glory and uploaded it on youtube.

@teeberg
Copy link
Contributor Author

teeberg commented Jan 24, 2015

Thanks for the note, I already saw it! :) I didn't realise it would be such a pain! I'll stick with my local SSH script then in the meantime. :-) Thanks for merging everything else in!

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

Successfully merging this pull request may close these issues.

None yet

3 participants