if ret:
raise GitRepositoryError("Not a Git repository object: '%s'" % obj)
return out[0].strip()
+
+ def list_tree(self, treeish, recurse=False):
+ """
+ Get a trees content. It returns a list of objects that match the
+ 'ls-tree' output: [ mode, type, sha1, path ].
+
+ @param treeish: the treeish object to list
+ @type treeish: C{str}
+ @param recurse: whether to list the tree recursively
+ @type recurse: C{bool}
+ @return: the tree
+ @rtype: C{list} of objects. See above.
+ """
+ args = GitArgs('-z')
+ args.add_true(recurse, '-r')
+ args.add(treeish)
+
+ out, err, ret = self._git_inout('ls-tree', args.args, capture_stderr=True)
+ if ret:
+ raise GitRepositoryError("Failed to ls-tree '%s': '%s'" % (treeish, err))
+
+ tree = []
+ for line in out.split('\0'):
+ if line:
+ tree.append(line.split(None, 3))
+ return tree
+
#}
def get_config(self, name):
True
"""
+
+def test_list_tree():
+ """
+ Test git-ls-tree
+
+ Methods tested:
+ - L{gbp.git.GitRepository.list_tree}
+
+ >>> import gbp.git
+ >>> repo = gbp.git.GitRepository(repo_dir)
+ >>> repo.list_tree('HEAD')
+ [['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile']]
+ """
+
def test_update_submodules():
"""
Updating submodules if we don't have any is a noop