diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-12-03 16:31:07 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-12-03 16:31:07 +0100 |
commit | c05ef0e7543c2845fd431420509476537fefe2b0 (patch) | |
tree | 75393ae080690acd035108d698d3c5a467076ebb /lib/git/utils.py | |
parent | 1eae9d1532e037a4eb08aaee79ff3233d2737f31 (diff) | |
download | gitpython-c05ef0e7543c2845fd431420509476537fefe2b0.tar.gz |
repo: renamed directories to more descriptive identifiers and made them safer to use in case of bare repositories
Diffstat (limited to 'lib/git/utils.py')
-rw-r--r-- | lib/git/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/git/utils.py b/lib/git/utils.py index 5deed556..433f96d5 100644 --- a/lib/git/utils.py +++ b/lib/git/utils.py @@ -362,3 +362,18 @@ class Iterable(object): """ raise NotImplementedError("To be implemented by Subclass") +def needs_working_tree(func): + """ + Decorator assuring the wrapped method may only run if the repository has a + working tree, hence it is not bare. + """ + def check_default_index(self, *args, **kwargs): + if self.repo.working_tree_dir is None: + raise AssertionError( "Cannot call %r bare git repositories" % func.__name__ ) + return func(self, *args, **kwargs) + # END wrpaper method + + check_default_index.__name__ = func.__name__ + return check_default_index + + |