@@ -618,16 +618,16 @@ def as_text(stdout_value):
618
618
def environment (self ):
619
619
return self ._environment
620
620
621
- def set_environment (self , ** kwargs ):
621
+ def update_environment (self , ** kwargs ):
622
622
"""
623
623
Set environment variables for future git invocations. Return all changed
624
624
values in a format that can be passed back into this function to revert
625
625
the changes:
626
626
627
627
``Examples``::
628
628
629
- old_env = self.set_environment (PWD='/tmp')
630
- self.set_environment (**old_env)
629
+ old_env = self.update_environment (PWD='/tmp')
630
+ self.update_environment (**old_env)
631
631
632
632
:param kwargs: environment variables to use for git processes
633
633
:return: dict that maps environment variables to their old values
@@ -648,23 +648,23 @@ def set_environment(self, **kwargs):
648
648
return old_env
649
649
650
650
@contextmanager
651
- def environment (self , ** kwargs ):
651
+ def with_environment (self , ** kwargs ):
652
652
"""
653
- A context manager around the above set_environment to restore the
653
+ A context manager around the above update_environment to restore the
654
654
environment back to its previous state after operation.
655
655
656
656
``Examples``::
657
657
658
- with self.environment (GIT_SSH='/bin/ssh_wrapper'):
658
+ with self.with_environment (GIT_SSH='/bin/ssh_wrapper'):
659
659
repo.remotes.origin.fetch()
660
660
661
- :param kwargs: see set_environment
661
+ :param kwargs: see update_environment
662
662
"""
663
- old_env = self .set_environment (** kwargs )
663
+ old_env = self .update_environment (** kwargs )
664
664
try :
665
665
yield
666
666
finally :
667
- self .set_environment (** old_env )
667
+ self .update_environment (** old_env )
668
668
669
669
@contextmanager
670
670
def sshkey (self , sshkey_file ):
@@ -682,7 +682,7 @@ def sshkey(self, sshkey_file):
682
682
this_dir = os .path .dirname (__file__ )
683
683
ssh_wrapper = os .path .join (this_dir , '..' , 'scripts' , 'ssh_wrapper.py' )
684
684
685
- with self .environment (GIT_SSH_KEY_FILE = sshkey_file , GIT_SSH = ssh_wrapper ):
685
+ with self .with_environment (GIT_SSH_KEY_FILE = sshkey_file , GIT_SSH = ssh_wrapper ):
686
686
yield
687
687
688
688
def transform_kwargs (self , split_single_char_options = False , ** kwargs ):
0 commit comments