From 15b6bbac7bce15f6f7d72618f51877455f3e0ee5 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 22 Dec 2016 12:35:30 +0100 Subject: 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 --- git/refs/tag.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'git/refs') 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 -- cgit v1.2.1