From ae6e26ed4abac8b5e4e0a893da5546cd165d48e7 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Sep 2016 11:23:22 +0200 Subject: 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 --- git/refs/tag.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'git') 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): -- cgit v1.2.1