summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-06-27 08:36:29 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-11-14 14:22:04 +0200
commit97d1a275a52d5ec9e49f8e68915fab84891888a9 (patch)
treed529cf13562a63afcd0853f5db608635c33f468d /gbp
parentd912991ea739c0cf138a67d8416d92fc06145592 (diff)
downloadgit-buildpackage-97d1a275a52d5ec9e49f8e68915fab84891888a9.tar.gz
git-buildpackage-97d1a275a52d5ec9e49f8e68915fab84891888a9.tar.bz2
git-buildpackage-97d1a275a52d5ec9e49f8e68915fab84891888a9.zip
GitRepository/has_submodules: add treeish argument
For defining a Git treeish which to look into, instead of the current working copy. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp')
-rw-r--r--gbp/git/repository.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 1b696406..6042cad7 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1781,18 +1781,23 @@ class GitRepository(object):
#{ Submodules
- def has_submodules(self):
+ def has_submodules(self, treeish=None):
"""
Does the repo have any submodules?
+ @param treeish: look into treeish
+ @type treeish: C{str}
@return: C{True} if the repository has any submodules, C{False}
otherwise
@rtype: C{bool}
"""
- if os.path.exists(os.path.join(self.path, '.gitmodules')):
+ if treeish:
+ try:
+ self.show('%s:.gitmodules' % treeish)
+ except GitRepositoryError:
+ return False
return True
- else:
- return False
+ return os.path.exists(os.path.join(self.path, '.gitmodules'))
def add_submodule(self, repo_path):