From 2e68d907022c84392597e05afc22d9fe06bf0927 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 21 Oct 2009 18:45:41 +0200 Subject: tree.traverse: Added prune functionality - previously the predciate did both, pruning and preventing to return items --- test/git/test_tree.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/git/test_tree.py') diff --git a/test/git/test_tree.py b/test/git/test_tree.py index dafb6f3f..b359e2d2 100644 --- a/test/git/test_tree.py +++ b/test/git/test_tree.py @@ -35,6 +35,11 @@ class TestTree(TestCase): trees = list(root.traverse(predicate = trees_only)) assert len(trees) == len(list( i for i in root.traverse() if trees_only(i) )) + # test prune + lib_folder = lambda t: t.path == "lib" + pruned_trees = list(root.traverse(predicate = trees_only,prune = lib_folder)) + assert len(pruned_trees) < len(trees) + # trees and blobs assert len(set(trees)|set(root.trees)) == len(trees) assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len( root.blobs ) -- cgit v1.2.1 From 3cb5ba18ab1a875ef6b62c65342de476be47871b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 3 Nov 2009 16:35:33 +0100 Subject: object: renamed id attribute to sha as it in fact is always being rewritten as sha, even if the passed in id was a ref. This is done to assure objects are uniquely identified and will compare correctly --- test/git/test_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_tree.py') diff --git a/test/git/test_tree.py b/test/git/test_tree.py index b359e2d2..64a7900a 100644 --- a/test/git/test_tree.py +++ b/test/git/test_tree.py @@ -45,5 +45,5 @@ class TestTree(TestCase): assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len( root.blobs ) def test_repr(self): - tree = Tree(self.repo, id='abc') + tree = Tree(self.repo, 'abc') assert_equal('', repr(tree)) -- cgit v1.2.1 From c4cde8df886112ee32b0a09fcac90c28c85ded7f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 4 Nov 2009 12:46:37 +0100 Subject: IndexObject: assured that .path fields are relative to the repository ( previously it would just be a name ) added abspath property and name property to provide easy access to most common paths of an index object --- test/git/test_tree.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/git/test_tree.py') diff --git a/test/git/test_tree.py b/test/git/test_tree.py index 64a7900a..7b66743f 100644 --- a/test/git/test_tree.py +++ b/test/git/test_tree.py @@ -4,6 +4,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php +import os from test.testlib import * from git import * @@ -43,6 +44,19 @@ class TestTree(TestCase): # trees and blobs assert len(set(trees)|set(root.trees)) == len(trees) assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len( root.blobs ) + subitem = trees[0][0] + assert "/" in subitem.path + assert subitem.name == os.path.basename(subitem.path) + + # assure that at some point the traversed paths have a slash in them + found_slash = False + for item in root.traverse(): + assert os.path.isabs(item.abspath) + if '/' in item.path: + found_slash = True + break + # END for each item + assert found_slash def test_repr(self): tree = Tree(self.repo, 'abc') -- cgit v1.2.1 From f41d42ee7e264ce2fc32cea555e5f666fa1b1fe9 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 4 Nov 2009 13:17:37 +0100 Subject: Improved cmd error handling in case an invalid revision is specified for an object repo.tree: improved to be less restricting --- test/git/test_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_tree.py') diff --git a/test/git/test_tree.py b/test/git/test_tree.py index 7b66743f..e0c1f134 100644 --- a/test/git/test_tree.py +++ b/test/git/test_tree.py @@ -16,7 +16,7 @@ class TestTree(TestCase): def test_traverse(self): - root = self.repo.tree() + root = self.repo.tree('0.1.6') num_recursive = 0 all_items = list() for obj in root.traverse(): -- cgit v1.2.1