@@ -439,6 +439,10 @@ 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+
442446 @property
443447 def working_dir (self ):
444448 """:return: Git directory we are working on"""
@@ -541,6 +545,7 @@ def execute(self, command,
541545 # Start the process
542546 env = os .environ .copy ()
543547 env ["LC_MESSAGES" ] = "C"
548+ print (self ._environment )
544549 env .update (self ._environment )
545550
546551 proc = Popen (command ,
@@ -633,7 +638,7 @@ def update_environment(self, **kwargs):
633638 :return: dict that maps environment variables to their old values
634639 """
635640 old_env = {}
636- for key , value in kwargs .iteritems ():
641+ for key , value in kwargs .items ():
637642 # set value if it is None
638643 if value is not None :
639644 if key in self ._environment :
@@ -648,14 +653,14 @@ def update_environment(self, **kwargs):
648653 return old_env
649654
650655 @contextmanager
651- def with_environment (self , ** kwargs ):
656+ def custom_environment (self , ** kwargs ):
652657 """
653- A context manager around the above update_environment to restore the
658+ A context manager around the above `` update_environment`` method to restore the
654659 environment back to its previous state after operation.
655660
656661 ``Examples``::
657662
658- with self.with_environment (GIT_SSH='/bin/ssh_wrapper'):
663+ with self.custom_environment (GIT_SSH='/bin/ssh_wrapper'):
659664 repo.remotes.origin.fetch()
660665
661666 :param kwargs: see update_environment
@@ -667,22 +672,20 @@ def with_environment(self, **kwargs):
667672 self .update_environment (** old_env )
668673
669674 @contextmanager
670- def sshkey (self , sshkey_file ):
675+ def sshkey (self , sshkey_file_path ):
671676 """
672677 A context manager to temporarily set an SSH key for all operations that
673678 run inside it.
674679
675680 ``Examples``::
676681
677- with self.environment(GIT_SSH=project_dir+ 'deployment_key'):
682+ with self.sshkey( 'deployment_key'):
678683 repo.remotes.origin.fetch()
679684
680- :param sshkey_file : Path to a private SSH key file
685+ :param sshkey_file_path : Path to a private SSH key file
681686 """
682- this_dir = os .path .dirname (__file__ )
683- ssh_wrapper = os .path .join (this_dir , '..' , 'scripts' , 'ssh_wrapper.py' )
684-
685- with self .with_environment (GIT_SSH_KEY_FILE = sshkey_file , GIT_SSH = ssh_wrapper ):
687+ ssh_wrapper = self ._sshkey_script_path ()
688+ with self .custom_environment (GIT_SSH_KEY_FILE = sshkey_file_path , GIT_SSH = ssh_wrapper ):
686689 yield
687690
688691 def transform_kwargs (self , split_single_char_options = False , ** kwargs ):
0 commit comments