diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-09-11 11:23:22 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2016-09-11 11:23:22 +0200 |
commit | ae6e26ed4abac8b5e4e0a893da5546cd165d48e7 (patch) | |
tree | 9ad92cf202f39ea4aa991572cb7fae25760e405e | |
parent | df65f51de6ba67138a48185ff2e63077f7fe7ce6 (diff) | |
download | gitpython-ae6e26ed4abac8b5e4e0a893da5546cd165d48e7.tar.gz |
fix(tag): resolve `commit` objects deeply.
As TagObjects can point to other TagObjects, we need
to keep going in order to resolve the final commit.
Fixes #503
-rw-r--r-- | doc/source/changes.rst | 6 | ||||
-rw-r--r-- | git/refs/tag.py | 14 |
2 files changed, 13 insertions, 7 deletions
diff --git a/doc/source/changes.rst b/doc/source/changes.rst index bba538be..1feacab8 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -2,6 +2,12 @@ Changelog ========= +2.0.9 - Bugfixes +============================= + +* `tag.commit` will now resolve commits deeply. + +* `DiffIndex.iter_change_type(...)` produces better results when diffing 2.0.8 - Features and Bugfixes ============================= diff --git a/git/refs/tag.py b/git/refs/tag.py index 3334e53c..11dbab97 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -24,13 +24,13 @@ class TagReference(Reference): def commit(self): """:return: Commit object the tag ref points to""" obj = self.object - if obj.type == "commit": - return obj - elif obj.type == "tag": - # it is a tag object which carries the commit as an object - we can point to anything - return obj.object - else: - raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self) + while obj.type != 'commit': + if obj.type == "tag": + # it is a tag object which carries the commit as an object - we can point to anything + obj = obj.object + else: + raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self) + return obj @property def tag(self): |