| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,8 @@ | |||
| 17 | 17 | import abc | |
| 18 | 18 | import os | |
| 19 | 19 | ||
| 20 | + from functools import wraps | ||
| 21 | + | ||
| 20 | 22 | from git.odict import OrderedDict | |
| 21 | 23 | from git.util import LockFile | |
| 22 | 24 | from git.compat import ( | |
@@ -67,11 +69,11 @@ def __new__(metacls, name, bases, clsdict): | |||
| 67 | 69 | def needs_values(func): | |
| 68 | 70 | """Returns method assuring we read values (on demand) before we try to access them""" | |
| 69 | 71 | ||
| 72 | + @wraps(func) | ||
| 70 | 73 | def assure_data_present(self, *args, **kwargs): | |
| 71 | 74 | self.read() | |
| 72 | 75 | return func(self, *args, **kwargs) | |
| 73 | 76 | # END wrapper method | |
| 74 | - assure_data_present.__name__ = func.__name__ | ||
| 75 | 77 | return assure_data_present | |
| 76 | 78 | ||
| 77 | 79 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,9 @@ | |||
| 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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,8 @@ | |||
| 12 | 12 | import io | |
| 13 | 13 | import logging | |
| 14 | 14 | ||
| 15 | + from functools import wraps | ||
| 16 | + | ||
| 15 | 17 | from git import Repo, Remote, GitCommandError, Git | |
| 16 | 18 | from git.util import rmtree | |
| 17 | 19 | from git.compat import string_types, is_win | |
@@ -86,6 +88,7 @@ def with_rw_directory(func): | |||
| 86 | 88 | """Create a temporary directory which can be written to, remove it if the | |
| 87 | 89 | test succeeds, but leave it otherwise to aid additional debugging""" | |
| 88 | 90 | ||
| 91 | + @wraps(func) | ||
| 89 | 92 | def wrapper(self): | |
| 90 | 93 | path = tempfile.mktemp(prefix=func.__name__) | |
| 91 | 94 | os.mkdir(path) | |
@@ -122,6 +125,7 @@ def with_rw_repo(working_tree_ref, bare=False): | |||
| 122 | 125 | assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout" | |
| 123 | 126 | ||
| 124 | 127 | def argument_passer(func): | |
| 128 | + @wraps(func) | ||
| 125 | 129 | def repo_creator(self): | |
| 126 | 130 | prefix = 'non_' | |
| 127 | 131 | if bare: | |
@@ -155,7 +159,6 @@ def repo_creator(self): | |||
| 155 | 159 | # END rm test repo if possible | |
| 156 | 160 | # END cleanup | |
| 157 | 161 | # END rw repo creator | |
| 158 | - repo_creator.__name__ = func.__name__ | ||
| 159 | 162 | return repo_creator | |
| 160 | 163 | # END argument passer | |
| 161 | 164 | return argument_passer | |
@@ -211,6 +214,7 @@ def case(self, rw_repo, rw_remote_repo) | |||
| 211 | 214 | ||
| 212 | 215 | def argument_passer(func): | |
| 213 | 216 | ||
| 217 | + @wraps(func) | ||
| 214 | 218 | def remote_repo_creator(self): | |
| 215 | 219 | remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__) | |
| 216 | 220 | repo_dir = _mktemp("remote_clone_non_bare_repo") | |
@@ -319,10 +323,9 @@ def remote_repo_creator(self): | |||
| 319 | 323 | gd.proc.wait() | |
| 320 | 324 | # END cleanup | |
| 321 | 325 | # END bare repo creator | |
| 322 | - remote_repo_creator.__name__ = func.__name__ | ||
| 323 | 326 | return remote_repo_creator | |
| 324 | 327 | # END remote repo creator | |
| 325 | - # END argument parsser | ||
| 328 | + # END argument parser | ||
| 326 | 329 | ||
| 327 | 330 | return argument_passer | |
| 328 | 331 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,8 @@ | |||
| 14 | 14 | import stat | |
| 15 | 15 | import time | |
| 16 | 16 | ||
| 17 | + from functools import wraps | ||
| 18 | + | ||
| 17 | 19 | from git.compat import is_win | |
| 18 | 20 | from gitdb.util import ( # NOQA | |
| 19 | 21 | make_sha, | |
@@ -50,13 +52,13 @@ def unbare_repo(func): | |||
| 50 | 52 | """Methods with this decorator raise InvalidGitRepositoryError if they | |
| 51 | 53 | encounter a bare repository""" | |
| 52 | 54 | ||
| 55 | + @wraps(func) | ||
| 53 | 56 | def wrapper(self, *args, **kwargs): | |
| 54 | 57 | if self.repo.bare: | |
| 55 | 58 | raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__) | |
| 56 | 59 | # END bare method | |
| 57 | 60 | return func(self, *args, **kwargs) | |
| 58 | 61 | # END wrapper | |
| 59 | - wrapper.__name__ = func.__name__ | ||
| 60 | 62 | return wrapper | |
| 61 | 63 | ||
| 62 | 64 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments