Skip to content

Commit 4df4159

Browse files
committed
Removed Git.sshkey() as it couldn't be distributed properly.
However, I kept information on how to achieve the same thing with `custom_environment()` in the test. Related to #234
1 parent f3d91ca commit 4df4159

File tree

8 files changed

+14
-44
lines changed

8 files changed

+14
-44
lines changed

Diff for: MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ include CHANGES
44
include AUTHORS
55
include README
66
include requirements.txt
7-
include git/scripts/ssh_wrapper.sh
87

98
graft git/test/fixtures
109
graft git/test/performance

Diff for: doc/source/tutorial.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ You can easily access configuration information for a remote by accessing option
331331
:start-after: # [26-test_references_and_objects]
332332
:end-before: # ![26-test_references_and_objects]
333333

334-
You can also specify an SSH key to use for any operations on the remotes
334+
You can also specify per-call custom environments using a new context manager on the Git command
335335

336336
.. literalinclude:: ../../git/test/test_docs.py
337337
:language: python

Diff for: git/cmd.py

-21
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,6 @@ def _set_cache_(self, attr):
439439
super(Git, self)._set_cache_(attr)
440440
# END handle version info
441441

442-
def _sshkey_script_path(self):
443-
this_dir = os.path.dirname(__file__)
444-
return os.path.join(this_dir, 'scripts', 'ssh_wrapper.sh')
445-
446442
@property
447443
def working_dir(self):
448444
""":return: Git directory we are working on"""
@@ -670,23 +666,6 @@ def custom_environment(self, **kwargs):
670666
finally:
671667
self.update_environment(**old_env)
672668

673-
@contextmanager
674-
def sshkey(self, sshkey_file_path):
675-
"""
676-
A context manager to temporarily set an SSH key for all operations that
677-
run inside it.
678-
679-
``Examples``::
680-
681-
with self.sshkey('deployment_key'):
682-
repo.remotes.origin.fetch()
683-
684-
:param sshkey_file_path: Path to a private SSH key file
685-
"""
686-
ssh_wrapper = self._sshkey_script_path()
687-
with self.custom_environment(GIT_SSH_KEY_FILE=sshkey_file_path, GIT_SSH=ssh_wrapper):
688-
yield
689-
690669
def transform_kwargs(self, split_single_char_options=False, **kwargs):
691670
"""Transforms Python style kwargs into git command line options."""
692671
args = list()

Diff for: git/ext/gitdb

Submodule gitdb updated 1 file

Diff for: git/scripts/ssh_wrapper.sh

-2
This file was deleted.

Diff for: git/test/test_docs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ def test_references_and_objects(self, rw_dir):
438438
# ![31-test_references_and_objects]
439439

440440
# [32-test_references_and_objects]
441-
private_key_file = os.path.join(rw_dir, 'id_rsa_deployment_key')
442-
with repo.git.sshkey(private_key_file):
441+
ssh_executable = os.path.join(rw_dir, 'my_ssh_executable.sh')
442+
with repo.git.custom_environment(GIT_SSH=ssh_executable):
443443
# Note that we don't actually make the call here, as our test-setup doesn't permit it to
444444
# succeed.
445445
# It will in your case :)

Diff for: git/test/test_git.py

+9-15
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,17 @@ def test_environment(self, rw_dir):
181181
assert new_env == {'VARKEY': 'VARVALUE'}
182182
assert self.git.environment() == {}
183183

184-
class TestRepo(Repo):
185-
class GitCommandWrapperType(Git):
186-
def _sshkey_script_path(self):
187-
path = os.path.join(rw_dir, 'failing-script.sh')
188-
stream = open(path, 'wt')
189-
stream.write("#!/usr/bin/env sh\n" +
190-
"echo FOO\n")
191-
stream.close()
192-
os.chmod(path, 0o555)
193-
return path
194-
# end Git
195-
# end Repo
196-
197-
rw_repo = TestRepo.init(os.path.join(rw_dir, 'repo'))
184+
path = os.path.join(rw_dir, 'failing-script.sh')
185+
stream = open(path, 'wt')
186+
stream.write("#!/usr/bin/env sh\n" +
187+
"echo FOO\n")
188+
stream.close()
189+
os.chmod(path, 0o555)
190+
191+
rw_repo = Repo.init(os.path.join(rw_dir, 'repo'))
198192
remote = rw_repo.create_remote('ssh-origin', "ssh://git@server/foo")
199193

200-
with rw_repo.git.sshkey('doesntexist.key'):
194+
with rw_repo.git.custom_environment(GIT_SSH=path):
201195
try:
202196
remote.fetch()
203197
except GitCommandError as err:

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _stamp_version(filename):
8282
url="https://github.com/gitpython-developers/GitPython",
8383
packages=find_packages('.'),
8484
py_modules=['git.' + f[:-3] for f in os.listdir('./git') if f.endswith('.py')],
85-
package_data={'git.test': ['fixtures/*'], 'git' : ['scripts/*']},
85+
package_data={'git.test': ['fixtures/*']},
8686
package_dir={'git': 'git'},
8787
license="BSD License",
8888
requires=['gitdb (>=0.6.4)'],

0 commit comments

Comments
 (0)