2
2
import struct
3
3
import tempfile
4
4
import os
5
+
6
+ from functools import wraps
7
+
5
8
from git .compat import is_win
6
9
7
10
__all__ = ('TemporaryFileSwap' , 'post_clear_cache' , 'default_index' , 'git_working_dir' )
@@ -48,13 +51,13 @@ def post_clear_cache(func):
48
51
natively which in fact is possible, but probably not feasible performance wise.
49
52
"""
50
53
54
+ @wraps (func )
51
55
def post_clear_cache_if_not_raised (self , * args , ** kwargs ):
52
56
rval = func (self , * args , ** kwargs )
53
57
self ._delete_entries_cache ()
54
58
return rval
55
-
56
59
# END wrapper method
57
- post_clear_cache_if_not_raised . __name__ = func . __name__
60
+
58
61
return post_clear_cache_if_not_raised
59
62
60
63
@@ -63,21 +66,22 @@ def default_index(func):
63
66
repository index. This is as we rely on git commands that operate
64
67
on that index only. """
65
68
69
+ @wraps (func )
66
70
def check_default_index (self , * args , ** kwargs ):
67
71
if self ._file_path != self ._index_path ():
68
72
raise AssertionError (
69
73
"Cannot call %r on indices that do not represent the default git index" % func .__name__ )
70
74
return func (self , * args , ** kwargs )
71
75
# END wrpaper method
72
76
73
- check_default_index .__name__ = func .__name__
74
77
return check_default_index
75
78
76
79
77
80
def git_working_dir (func ):
78
81
"""Decorator which changes the current working dir to the one of the git
79
82
repository in order to assure relative paths are handled correctly"""
80
83
84
+ @wraps (func )
81
85
def set_git_working_dir (self , * args , ** kwargs ):
82
86
cur_wd = os .getcwd ()
83
87
os .chdir (self .repo .working_tree_dir )
@@ -88,7 +92,6 @@ def set_git_working_dir(self, *args, **kwargs):
88
92
# END handle working dir
89
93
# END wrapper
90
94
91
- set_git_working_dir .__name__ = func .__name__
92
95
return set_git_working_dir
93
96
94
97
#} END decorators
0 commit comments