diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-21 18:56:29 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-21 18:57:34 +0100 |
commit | d565a874f29701531ce1fc0779592838040d3edf (patch) | |
tree | c2ba9a69ae90eedc01616b409a179baf705a3feb /git/util.py | |
parent | e4d3809161fc54d6913c0c2c7f6a7b51eebe223f (diff) | |
download | gitpython-d565a874f29701531ce1fc0779592838040d3edf.tar.gz |
Fixed regression in test-suite for IndexFile
Previously, it checked for AssertionErrors, now we have to implement
need-unbare-repo check ourselves.
Diffstat (limited to 'git/util.py')
-rw-r--r-- | git/util.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/git/util.py b/git/util.py index 06fefcc3..02c54bc3 100644 --- a/git/util.py +++ b/git/util.py @@ -16,7 +16,11 @@ import threading # NOTE: Some of the unused imports might be used/imported by others. # Handle once test-cases are back up and running. -from .exc import GitCommandError +from .exc import ( + GitCommandError, + InvalidGitRepositoryError +) + from .compat import ( MAXSIZE, defenc, @@ -37,11 +41,25 @@ from gitdb.util import ( # NOQA __all__ = ("stream_copy", "join_path", "to_native_path_windows", "to_native_path_linux", "join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList", "BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists', - 'RemoteProgress', 'rmtree', 'WaitGroup') + 'RemoteProgress', 'rmtree', 'WaitGroup', 'unbare_repo') #{ Utility Methods +def unbare_repo(func): + """Methods with this decorator raise InvalidGitRepositoryError if they + encounter a bare repository""" + + def wrapper(self, *args, **kwargs): + if self.repo.bare: + raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__) + # END bare method + return func(self, *args, **kwargs) + # END wrapper + wrapper.__name__ = func.__name__ + return wrapper + + def rmtree(path): """Remove the given recursively. |