summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-22 19:04:57 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-22 19:04:57 +0100
commit4df4159413a4bf30a891f21cd69202e8746c8fea (patch)
treee44615e5382204ad60ba2eaa9e90b6021b270a2a
parentf3d91ca75500285d19c6ae2d4bf018452ad822a6 (diff)
downloadgitpython-0.3.6.tar.gz
Removed Git.sshkey() as it couldn't be distributed properly.0.3.6
However, I kept information on how to achieve the same thing with `custom_environment()` in the test. Related to #234
-rw-r--r--MANIFEST.in1
-rw-r--r--doc/source/tutorial.rst2
-rw-r--r--git/cmd.py21
m---------git/ext/gitdb0
-rwxr-xr-xgit/scripts/ssh_wrapper.sh2
-rw-r--r--git/test/test_docs.py4
-rw-r--r--git/test/test_git.py24
-rwxr-xr-xsetup.py2
8 files changed, 13 insertions, 43 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index 028d3619..c84a9dd3 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,7 +4,6 @@ include CHANGES
include AUTHORS
include README
include requirements.txt
-include git/scripts/ssh_wrapper.sh
graft git/test/fixtures
graft git/test/performance
diff --git a/doc/source/tutorial.rst b/doc/source/tutorial.rst
index 7f57ec94..0d60f0aa 100644
--- a/doc/source/tutorial.rst
+++ b/doc/source/tutorial.rst
@@ -331,7 +331,7 @@ You can easily access configuration information for a remote by accessing option
:start-after: # [26-test_references_and_objects]
:end-before: # ![26-test_references_and_objects]
-You can also specify an SSH key to use for any operations on the remotes
+You can also specify per-call custom environments using a new context manager on the Git command
.. literalinclude:: ../../git/test/test_docs.py
:language: python
diff --git a/git/cmd.py b/git/cmd.py
index 960b2a21..7e15d4ea 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -439,10 +439,6 @@ class Git(LazyMixin):
super(Git, self)._set_cache_(attr)
# END handle version info
- def _sshkey_script_path(self):
- this_dir = os.path.dirname(__file__)
- return os.path.join(this_dir, 'scripts', 'ssh_wrapper.sh')
-
@property
def working_dir(self):
""":return: Git directory we are working on"""
@@ -670,23 +666,6 @@ class Git(LazyMixin):
finally:
self.update_environment(**old_env)
- @contextmanager
- def sshkey(self, sshkey_file_path):
- """
- A context manager to temporarily set an SSH key for all operations that
- run inside it.
-
- ``Examples``::
-
- with self.sshkey('deployment_key'):
- repo.remotes.origin.fetch()
-
- :param sshkey_file_path: Path to a private SSH key file
- """
- ssh_wrapper = self._sshkey_script_path()
- with self.custom_environment(GIT_SSH_KEY_FILE=sshkey_file_path, GIT_SSH=ssh_wrapper):
- yield
-
def transform_kwargs(self, split_single_char_options=False, **kwargs):
"""Transforms Python style kwargs into git command line options."""
args = list()
diff --git a/git/ext/gitdb b/git/ext/gitdb
-Subproject b3237e804ae313503f5479349f90066c356b154
+Subproject 9aae93ea584c8cf9d1539a60e41c5c37119401d
diff --git a/git/scripts/ssh_wrapper.sh b/git/scripts/ssh_wrapper.sh
deleted file mode 100755
index bc0ab024..00000000
--- a/git/scripts/ssh_wrapper.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-ssh -i "$GIT_SSH_KEY_FILE" $@
diff --git a/git/test/test_docs.py b/git/test/test_docs.py
index 175e728a..8dfef1c6 100644
--- a/git/test/test_docs.py
+++ b/git/test/test_docs.py
@@ -438,8 +438,8 @@ class Tutorials(TestBase):
# ![31-test_references_and_objects]
# [32-test_references_and_objects]
- private_key_file = os.path.join(rw_dir, 'id_rsa_deployment_key')
- with repo.git.sshkey(private_key_file):
+ ssh_executable = os.path.join(rw_dir, 'my_ssh_executable.sh')
+ with repo.git.custom_environment(GIT_SSH=ssh_executable):
# Note that we don't actually make the call here, as our test-setup doesn't permit it to
# succeed.
# It will in your case :)
diff --git a/git/test/test_git.py b/git/test/test_git.py
index 18acd77e..8087bc45 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -181,23 +181,17 @@ class TestGit(TestBase):
assert new_env == {'VARKEY': 'VARVALUE'}
assert self.git.environment() == {}
- class TestRepo(Repo):
- class GitCommandWrapperType(Git):
- def _sshkey_script_path(self):
- path = os.path.join(rw_dir, 'failing-script.sh')
- stream = open(path, 'wt')
- stream.write("#!/usr/bin/env sh\n" +
- "echo FOO\n")
- stream.close()
- os.chmod(path, 0o555)
- return path
- # end Git
- # end Repo
-
- rw_repo = TestRepo.init(os.path.join(rw_dir, 'repo'))
+ path = os.path.join(rw_dir, 'failing-script.sh')
+ stream = open(path, 'wt')
+ stream.write("#!/usr/bin/env sh\n" +
+ "echo FOO\n")
+ stream.close()
+ os.chmod(path, 0o555)
+
+ rw_repo = Repo.init(os.path.join(rw_dir, 'repo'))
remote = rw_repo.create_remote('ssh-origin', "ssh://git@server/foo")
- with rw_repo.git.sshkey('doesntexist.key'):
+ with rw_repo.git.custom_environment(GIT_SSH=path):
try:
remote.fetch()
except GitCommandError as err:
diff --git a/setup.py b/setup.py
index d2d8f2fa..d35301ae 100755
--- a/setup.py
+++ b/setup.py
@@ -82,7 +82,7 @@ setup(
url="https://github.com/gitpython-developers/GitPython",
packages=find_packages('.'),
py_modules=['git.' + f[:-3] for f in os.listdir('./git') if f.endswith('.py')],
- package_data={'git.test': ['fixtures/*'], 'git' : ['scripts/*']},
+ package_data={'git.test': ['fixtures/*']},
package_dir={'git': 'git'},
license="BSD License",
requires=['gitdb (>=0.6.4)'],