summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-06 14:20:58 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-06 14:20:58 +0100
commit95bb489a50f6c254f49ba4562d423dbf2201554f (patch)
tree2f1a172cc8a81297dc16ae9634887ff7cffd93e7
parent4cfc682ff87d3629b31e0196004d1954810b206c (diff)
downloadgitpython-95bb489a50f6c254f49ba4562d423dbf2201554f.tar.gz
test_tree works
-rw-r--r--doc/source/changes.rst1
-rw-r--r--git/objects/tree.py12
-rw-r--r--git/test/test_tree.py1
3 files changed, 12 insertions, 2 deletions
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index 3b62ddc8..bb301f87 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -7,6 +7,7 @@ Changelog
* Internally, hexadecimal SHA1 are treated as ascii encoded strings. Binary SHA1 are treated as bytes.
* Id attribute of Commit objects is now `hexsha`, instead of `binsha`. The latter makes no sense in python 3 and I see no application of it anyway besides its artificial usage in test cases.
* **IMPORTANT**: If you were using the config_writer(), you implicitly relied on __del__ to work as expected to flush changes. To be sure changes are flushed under PY3, you will have to call the new `release()` method to trigger a flush. For some reason, __del__ is not called necessarily anymore when a symbol goes out of scope.
+* The `Tree` now has a `.join('name')` method which is equivalent to `tree / 'name'`
0.3.3
=====
diff --git a/git/objects/tree.py b/git/objects/tree.py
index 6776a15e..f9bee01e 100644
--- a/git/objects/tree.py
+++ b/git/objects/tree.py
@@ -159,7 +159,7 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
raise TypeError("Unknown mode %o found in tree data for path '%s'" % (mode, path))
# END for each item
- def __div__(self, file):
+ def join(self, file):
"""Find the named object in this tree's contents
:return: ``git.Blob`` or ``git.Tree`` or ``git.Submodule``
@@ -192,6 +192,14 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
raise KeyError(msg % file)
# END handle long paths
+ def __div__(self, file):
+ """For PY2 only"""
+ return self.join(file)
+
+ def __truediv__(self, file):
+ """For PY3 only"""
+ return self.join(file)
+
@property
def trees(self):
""":return: list(Tree, ...) list of trees directly below this tree"""
@@ -235,7 +243,7 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
if isinstance(item, string_types):
# compatability
- return self.__div__(item)
+ return self.join(item)
# END index is basestring
raise TypeError("Invalid index type: %r" % item)
diff --git a/git/test/test_tree.py b/git/test/test_tree.py
index 72bda485..246584ee 100644
--- a/git/test/test_tree.py
+++ b/git/test/test_tree.py
@@ -138,6 +138,7 @@ class TestTree(TestBase):
# END check for slash
# slashes in paths are supported as well
+ # NOTE: on py3, / doesn't work with strings anymore ...
assert root[item.path] == item == root / item.path
# END for each item
assert found_slash