Skip to content

Commit ae6e26e

Browse files
committed
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
1 parent df65f51 commit ae6e26e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

‎doc/source/changes.rst

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog
33
=========
44

5+
2.0.9 - Bugfixes
6+
=============================
7+
8+
* `tag.commit` will now resolve commits deeply.
9+
10+
* `DiffIndex.iter_change_type(...)` produces better results when diffing
511
2.0.8 - Features and Bugfixes
612
=============================
713

‎git/refs/tag.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class TagReference(Reference):
2424
def commit(self):
2525
""":return: Commit object the tag ref points to"""
2626
obj = self.object
27-
if obj.type == "commit":
28-
return obj
29-
elif obj.type == "tag":
30-
# it is a tag object which carries the commit as an object - we can point to anything
31-
return obj.object
32-
else:
33-
raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self)
27+
while obj.type != 'commit':
28+
if obj.type == "tag":
29+
# it is a tag object which carries the commit as an object - we can point to anything
30+
obj = obj.object
31+
else:
32+
raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self)
33+
return obj
3434

3535
@property
3636
def tag(self):

0 commit comments

Comments
 (0)