summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2016-12-22 12:35:30 +0100
committerSebastian Thiel <byronimo@gmail.com>2016-12-22 12:36:49 +0100
commit15b6bbac7bce15f6f7d72618f51877455f3e0ee5 (patch)
tree558d844f343eea32f5be21d8f1e5602cc4ddc75f
parentc823d482d03caa8238b48714af4dec6d9e476520 (diff)
downloadgitpython-15b6bbac7bce15f6f7d72618f51877455f3e0ee5.tar.gz
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
-rw-r--r--git/refs/tag.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/git/refs/tag.py b/git/refs/tag.py
index cf41d971..dc7d020d 100644
--- a/git/refs/tag.py
+++ b/git/refs/tag.py
@@ -22,14 +22,17 @@ class TagReference(Reference):
@property
def commit(self):
- """:return: Commit object the tag ref points to"""
+ """:return: Commit object the tag ref points to
+
+ :raise ValueError: if the tag points to a tree or blob"""
obj = self.object
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)
+ raise ValueError(("Cannot resolve commit as tag %s points to a %s object - "
+ + "use the `.object` property instead to access it") % (self, obj.type))
return obj
@property