GitRepository/has_submodules: add treeish argument
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 27 Jun 2014 05:36:29 +0000 (08:36 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 30 Jun 2014 15:28:15 +0000 (18:28 +0300)
For defining a Git treeish which to look into, instead of the current
working copy.

Change-Id: I27abd99f0416bd4300953d3c1bae2d99de3ab6c0
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/git/repository.py

index cd77915..6b21c25 100644 (file)
@@ -1879,18 +1879,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):