diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-15 18:42:44 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-15 18:42:44 +0100 |
commit | f97653aa06cf84bcf160be3786b6fce49ef52961 (patch) | |
tree | 03d5469f124ab166137196c16bf39f628c962185 /lib/git/repo/base.py | |
parent | 00ce31ad308ff4c7ef874d2fa64374f47980c85c (diff) | |
download | gitpython-f97653aa06cf84bcf160be3786b6fce49ef52961.tar.gz |
Repo: added submodule query and iteration methods similar to the ones provided for Remotes, including test
Diffstat (limited to 'lib/git/repo/base.py')
-rw-r--r-- | lib/git/repo/base.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/git/repo/base.py b/lib/git/repo/base.py index 790b1283..3a395af0 100644 --- a/lib/git/repo/base.py +++ b/lib/git/repo/base.py @@ -6,7 +6,6 @@ from git.exc import InvalidGitRepositoryError, NoSuchPathError from git.cmd import Git -from git.objects import Actor from git.refs import * from git.index import IndexFile from git.objects import * @@ -222,6 +221,27 @@ class Repo(object): """:return: Remote with the specified name :raise ValueError: if no remote with such a name exists""" return Remote(self, name) + + @property + def submodules(self): + """:return: git.IterableList(Submodule, ...) of direct submodules""" + return self.list_submodules(recursive=False) + + def submodule(self, name): + """:return: Submodule with the given name + :raise ValueError: If no such submodule exists""" + try: + return self.submodules[name] + except IndexError: + raise ValueError("Didn't find submodule named %r" % name) + # END exception handling + + def list_submodules(self, recursive=False): + """A list if Submodule objects available in this repository + :param recursive: If True, submodules of submodules (and so forth) will be + returned as well as part of a depth-first traversal + :return: ``git.IterableList(Submodule, ...)""" + return RootModule(self).list_traverse(ignore_self=1, depth = recursive and -1 or 1) @property def tags(self): |