| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f3d91ca commit 4df4159
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,6 @@ include CHANGES | |||
| 4 | 4 | include AUTHORS | |
| 5 | 5 | include README | |
| 6 | 6 | include requirements.txt | |
| 7 | - include git/scripts/ssh_wrapper.sh | ||
| 8 | 7 | ||
| 9 | 8 | graft git/test/fixtures | |
| 10 | 9 | graft git/test/performance | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -331,7 +331,7 @@ You can easily access configuration information for a remote by accessing option | |||
| 331 | 331 | :start-after: # [26-test_references_and_objects] | |
| 332 | 332 | :end-before: # ![26-test_references_and_objects] | |
| 333 | 333 | ||
| 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 | ||
| 335 | 335 | ||
| 336 | 336 | .. literalinclude:: ../../git/test/test_docs.py | |
| 337 | 337 | :language: python | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -439,10 +439,6 @@ def _set_cache_(self, attr): | |||
| 439 | 439 | super(Git, self)._set_cache_(attr) | |
| 440 | 440 | # END handle version info | |
| 441 | 441 | ||
| 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 | - | ||
| 446 | 442 | @property | |
| 447 | 443 | def working_dir(self): | |
| 448 | 444 | """:return: Git directory we are working on""" | |
@@ -670,23 +666,6 @@ def custom_environment(self, **kwargs): | |||
| 670 | 666 | finally: | |
| 671 | 667 | self.update_environment(**old_env) | |
| 672 | 668 | ||
| 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 | - | ||
| 690 | 669 | def transform_kwargs(self, split_single_char_options=False, **kwargs): | |
| 691 | 670 | """Transforms Python style kwargs into git command line options.""" | |
| 692 | 671 | args = list() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -438,8 +438,8 @@ def test_references_and_objects(self, rw_dir): | |||
| 438 | 438 | # ![31-test_references_and_objects] | |
| 439 | 439 | ||
| 440 | 440 | # [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): | ||
| 443 | 443 | # Note that we don't actually make the call here, as our test-setup doesn't permit it to | |
| 444 | 444 | # succeed. | |
| 445 | 445 | # It will in your case :) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,23 +181,17 @@ def test_environment(self, rw_dir): | |||
| 181 | 181 | assert new_env == {'VARKEY': 'VARVALUE'} | |
| 182 | 182 | assert self.git.environment() == {} | |
| 183 | 183 | ||
| 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')) | ||
| 198 | 192 | remote = rw_repo.create_remote('ssh-origin', "ssh://git@server/foo") | |
| 199 | 193 | ||
| 200 | - with rw_repo.git.sshkey('doesntexist.key'): | ||
| 194 | + with rw_repo.git.custom_environment(GIT_SSH=path): | ||
| 201 | 195 | try: | |
| 202 | 196 | remote.fetch() | |
| 203 | 197 | except GitCommandError as err: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,7 +82,7 @@ def _stamp_version(filename): | |||
| 82 | 82 | url="https://github.com/gitpython-developers/GitPython", | |
| 83 | 83 | packages=find_packages('.'), | |
| 84 | 84 | 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/*']}, | ||
| 86 | 86 | package_dir={'git': 'git'}, | |
| 87 | 87 | license="BSD License", | |
| 88 | 88 | requires=['gitdb (>=0.6.4)'], | |
| Back | FazBrowse Home | New Git URL |
0 commit comments