diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-09-06 15:06:20 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-09-09 09:16:04 +0300 |
commit | 87ca0a4f89b8422e2784f41a4d88eaf98b313c8c (patch) | |
tree | 1e3ca9ff752005f410988903ffb5758cc01af917 | |
parent | e3cd921a1c6098ba7ea58b223d2b9467cfc7bf76 (diff) | |
download | git-buildpackage-87ca0a4f89b8422e2784f41a4d88eaf98b313c8c.tar.gz git-buildpackage-87ca0a4f89b8422e2784f41a4d88eaf98b313c8c.tar.bz2 git-buildpackage-87ca0a4f89b8422e2784f41a4d88eaf98b313c8c.zip |
GitRepository.list_tree: add 'paths' option
Change-Id: I9331fec6fcd0e58dad7cb4a571a683e09ce08011
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/git/repository.py | 4 | ||||
-rw-r--r-- | tests/test_GitRepository.py | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 292d68c0..104f70fd 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1029,7 +1029,7 @@ class GitRepository(object): raise GitRepositoryError("Not a Git repository object: '%s'" % obj) return out[0].strip() - def list_tree(self, treeish, recurse=False): + def list_tree(self, treeish, recurse=False, paths=None): """ Get a trees content. It returns a list of objects that match the 'ls-tree' output: [ mode, type, sha1, path ]. @@ -1044,6 +1044,8 @@ class GitRepository(object): args = GitArgs('-z') args.add_true(recurse, '-r') args.add(treeish) + args.add("--") + args.add_cond(paths, paths) out, err, ret = self._git_inout('ls-tree', args.args, capture_stderr=True) if ret: diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index b619b5c7..bf24a505 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -845,8 +845,11 @@ def test_make_tree(): >>> head [['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile']] >>> head.append(['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile2']) - >>> repo.make_tree(head) + >>> newtree = repo.make_tree(head) + >>> newtree '745951810c9e22fcc6de9b23f05efd6ab5512123' + >>> repo.list_tree(newtree, recurse=False, paths='testfile') + [['100644', 'blob', '19af7398c894bc5e86e17259317e4db519e9241f', 'testfile']] """ |