Skip to content

Commit 15b6bba

Browse files
committed
fix(tag): improve tag resolution handling
The handling is similar, but the error message makes clear what is happening, and what can be done to handle such a case. Related to #561
1 parent c823d48 commit 15b6bba

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

git/refs/tag.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ class TagReference(Reference):
2222

2323
@property
2424
def commit(self):
25-
""":return: Commit object the tag ref points to"""
25+
""":return: Commit object the tag ref points to
26+
27+
:raise ValueError: if the tag points to a tree or blob"""
2628
obj = self.object
2729
while obj.type != 'commit':
2830
if obj.type == "tag":
2931
# it is a tag object which carries the commit as an object - we can point to anything
3032
obj = obj.object
3133
else:
32-
raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self)
34+
raise ValueError(("Cannot resolve commit as tag %s points to a %s object - "
35+
+ "use the `.object` property instead to access it") % (self, obj.type))
3336
return obj
3437

3538
@property

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy