On Fri, 2014-12-05 at 15:50 +0100, Guido Günther wrote: > Hi Markus, > On Tue, Dec 02, 2014 at 04:47:58PM +0200, Markus Lehtonen wrote: > > Hello, > > > > On Fri, 2014-11-28 at 14:55 +0100, Guido Günther wrote: > > > On Fri, Nov 28, 2014 at 12:11:01PM +0200, Markus Lehtonen wrote: > > > [..snip..] > > > > If you're willing to wait for few days I could look into this and > > > > provide > > > > a patchset with minimal pq-rpm implementation (i.e. all the new cmdline > > > > options, even configurable branch names, removed). What I'd like to have > > > > there are the unit tests. > > > > > > That would be awesome! I'd be great to have a second tool merged. > > > > The attached series implements an initial version of the pq-rpm tool. > > The first four patches (0001-0004) are required to make the actual > > pq-rpm tool to work correctly. The next four patches (0005-0008) are > > requirements for the unit tests. The last patch finally implements > > gbp-pq-rpm tool itself. > > > > This series (plus some additional features) is also available in > > feature/pq-rpm branch in my Github repository: > > git clone git://github.com/marquiz/git-buildpackage-rpm.git -b > > feature/pq-rpm > > I had a look at this branch an it looks great. I'd feel more > comfortable if we'd had a unit test for dump_tree with recursive > though (af39e32692ebedb4316b28851e10f737bf176105) - can you add that, > I can pull in the rest then.
You can find a patch with updated unit tests attached. I also updated and rebased my feature/pq-rpm branch in Github. Thanks, Markus
>From 3f19f417727004ce1d3f8a800451201b528efe77 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen <markus.lehto...@linux.intel.com> 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 <markus.lehto...@linux.intel.com> --- gbp/scripts/common/buildpackage.py | 12 +++++++++--- tests/04_test_submodules.py | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py index 0522cd6..2e53b78 100644 --- a/gbp/scripts/common/buildpackage.py +++ b/gbp/scripts/common/buildpackage.py @@ -101,13 +101,19 @@ def git_archive_single(treeish, output, prefix, comp_type, comp_level, comp_opts #{ 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 tree to output_dir" output_dir = os.path.dirname(export_dir) prefix = sanitize_prefix(os.path.basename(export_dir)) + if recursive: + paths = [] + else: + paths = ["'%s'" % nam for _mod, typ, _sha, nam in + repo.list_tree(treeish) if typ == 'blob'] pipe = pipes.Template() - pipe.prepend('git archive --format=tar --prefix=%s %s' % (prefix, treeish), '.-') + pipe.prepend('git archive --format=tar --prefix=%s %s -- %s' % + (prefix, treeish, ' '.join(paths)), '.-') pipe.append('tar -C %s -xf -' % output_dir, '-.') top = os.path.abspath(os.path.curdir) try: @@ -115,7 +121,7 @@ def dump_tree(repo, export_dir, treeish, with_submodules): if ret: raise GbpError("Error in dump_tree archive pipe") - if with_submodules: + if recursive and with_submodules: if repo.has_submodules(): repo.update_submodules() for (subdir, commit) in repo.get_submodules(treeish): diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py index 4b07220..a18f8b5 100644 --- a/tests/04_test_submodules.py +++ b/tests/04_test_submodules.py @@ -22,6 +22,7 @@ SUBMODULES = [] SUBMODULE_NAMES = ["test_submodule", "sub module"] TMPDIR = None TESTFILE_NAME = "testfile" +TESTDIR_NAME = "testdir" class Submodule(object): """Class representing remote repo for Git submodule""" @@ -57,6 +58,8 @@ def test_empty_has_submodules(): def _add_dummy_data(repo, msg): """Commit dummy data to a Git repository""" shutil.copy(".git/HEAD", TESTFILE_NAME) + os.mkdir(TESTDIR_NAME) + shutil.copy(TESTFILE_NAME, os.path.join(TESTDIR_NAME, TESTFILE_NAME)) repo.add_files('.', force=True) repo.commit_all(msg) @@ -99,8 +102,16 @@ def test_dump_tree(): os.mkdir(dumpdir) ok_(buildpackage.dump_tree(REPO, dumpdir, "master", True)) ok_(os.path.exists(os.path.join(dumpdir, TESTFILE_NAME))) + ok_(os.path.exists(os.path.join(dumpdir, TESTDIR_NAME, TESTFILE_NAME))) ok_(os.path.exists(os.path.join(dumpdir, SUBMODULES[0].name, TESTFILE_NAME))) + # No submodules or subdirs if recursive is False + dumpdir = TMPDIR.join("dump2") + os.mkdir(dumpdir) + ok_(buildpackage.dump_tree(REPO, dumpdir, "master", True, False)) + ok_(os.path.exists(os.path.join(dumpdir, TESTFILE_NAME))) + ok_(not os.path.exists(os.path.join(dumpdir, TESTDIR_NAME))) + ok_(not os.path.exists(os.path.join(dumpdir, SUBMODULES[0].name))) def test_create_tarballs(): @@ -120,12 +131,12 @@ def test_check_tarfiles(): tarobj = tarfile.open(TMPDIR.join("test_0.1.orig.tar.bz2"), 'r:*') files = tarobj.getmembers() ok_("test-0.1/.gitmodules" in [ f.name for f in files ]) - eq_(len(files) , 6) + eq_(len(files) , 10) # Check tarball without submodules tarobj = tarfile.open(TMPDIR.join("test_0.2.orig.tar.bz2"), 'r:*') files = tarobj.getmembers() ok_(("test-0.2/%s" % TESTFILE_NAME) in [ f.name for f in files ]) - eq_(len(files) , 4) + eq_(len(files) , 6) def test_add_whitespace_submodule(): """Add a second submodule with name containing whitespace""" -- 1.8.4.5