From 489da2b3f119088e85ade4b02963953c6025ba80 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 17 Sep 2013 15:13:40 +0300 Subject: [PATCH] buildpackage/dump_tree: add 'recursive' option For selecting whether to dump all the files recursively or just the top level directory of the tree. Signed-off-by: Markus Lehtonen --- gbp/scripts/common/buildpackage.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py index c275292..be5b544 100644 --- a/gbp/scripts/common/buildpackage.py +++ b/gbp/scripts/common/buildpackage.py @@ -144,14 +144,19 @@ def untar_data(outdir, data): raise GbpError("Error extracting tar to %s" % outdir) #{ 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, -- 2.7.4