buildpackage/dump_tree: add 'recursive' option
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 17 Sep 2013 12:13:40 +0000 (15:13 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Nov 2014 12:22:01 +0000 (14:22 +0200)
For selecting whether to dump all the files recursively or just the top
level directory of the tree.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/common/buildpackage.py

index 56e4cb0..898f675 100644 (file)
@@ -131,14 +131,19 @@ def untar_data(outdir, data):
 
 
 #{ Functions to handle export-dir
-def dump_tree(repo, export_dir, treeish, with_submodules):
+def dump_tree(repo, export_dir, treeish, with_submodules, recursive=True):
     """Dump a git tree-ish to output_dir"""
     if not os.path.exists(export_dir):
         os.makedirs(export_dir)
+    if recursive:
+        paths = ''
+    else:
+        paths = [nam for _mod, typ, _sha, nam in repo.list_tree(treeish) if
+                    typ == 'blob']
     try:
-        data = repo.archive('tar', '', None, treeish)
+        data = repo.archive('tar', '', None, treeish, paths)
         untar_data(export_dir, data)
-        if with_submodules and repo.has_submodules():
+        if recursive and with_submodules and repo.has_submodules():
             repo.update_submodules()
             for (subdir, commit) in repo.get_submodules(treeish):
                 gbp.log.info("Processing submodule %s (%s)" % (subdir,