22import struct
33import tempfile
44import os
5+
6+ from functools import wraps
7+
58from git .compat import is_win
69
710__all__ = ('TemporaryFileSwap' , 'post_clear_cache' , 'default_index' , 'git_working_dir' )
@@ -48,13 +51,13 @@ def post_clear_cache(func):
4851 natively which in fact is possible, but probably not feasible performance wise.
4952 """
5053
54+ @wraps (func )
5155 def post_clear_cache_if_not_raised (self , * args , ** kwargs ):
5256 rval = func (self , * args , ** kwargs )
5357 self ._delete_entries_cache ()
5458 return rval
55-
5659 # END wrapper method
57- post_clear_cache_if_not_raised . __name__ = func . __name__
60+
5861 return post_clear_cache_if_not_raised
5962
6063
@@ -63,21 +66,22 @@ def default_index(func):
6366 repository index. This is as we rely on git commands that operate
6467 on that index only. """
6568
69+ @wraps (func )
6670 def check_default_index (self , * args , ** kwargs ):
6771 if self ._file_path != self ._index_path ():
6872 raise AssertionError (
6973 "Cannot call %r on indices that do not represent the default git index" % func .__name__ )
7074 return func (self , * args , ** kwargs )
7175 # END wrpaper method
7276
73- check_default_index .__name__ = func .__name__
7477 return check_default_index
7578
7679
7780def git_working_dir (func ):
7881 """Decorator which changes the current working dir to the one of the git
7982 repository in order to assure relative paths are handled correctly"""
8083
84+ @wraps (func )
8185 def set_git_working_dir (self , * args , ** kwargs ):
8286 cur_wd = os .getcwd ()
8387 os .chdir (self .repo .working_tree_dir )
@@ -88,7 +92,6 @@ def set_git_working_dir(self, *args, **kwargs):
8892 # END handle working dir
8993 # END wrapper
9094
91- set_git_working_dir .__name__ = func .__name__
9295 return set_git_working_dir
9396
9497#} END decorators
0 commit comments