From 61664129e37a49d447a5c9ddba73e888d7cd5ad3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 03 2017 10:22:13 +0000 Subject: Fixing showing tags even when some of them are not formatted as expected We encountered in https://pagure.io/pagure/issue/1991 an issue where some tags objects were not formatted as libgit2 expects them to be. In this case, there were no email attached to the person doing the tag, the tagger, and libgit2 would raise an ValueError exception on this. With this commit, since we cannot access the object, we just catch this exception and move on. It's a pity since we will not be able to show these tags, but at least we will be able to show the rest of them. Fixes https://pagure.io/pagure/issue/1991 --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 0311f0e..ed6582c 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1466,8 +1466,11 @@ def get_git_tags_objects(project): tags = {} for tag in repo_obj.listall_references(): if 'refs/tags/' in tag and repo_obj.lookup_reference(tag): - commit_time = "" - theobject = repo_obj[repo_obj.lookup_reference(tag).target] + commit_time = None + try: + theobject = repo_obj[repo_obj.lookup_reference(tag).target] + except ValueError: + theobject = None objecttype = "" if isinstance(theobject, pygit2.Tag): commit_time = theobject.get_object().commit_time @@ -1477,7 +1480,7 @@ def get_git_tags_objects(project): objecttype = "commit" tags[commit_time] = { - "object": repo_obj[repo_obj.lookup_reference(tag).target], + "object": theobject, "tagname": tag.replace("refs/tags/", ""), "date": commit_time, "objecttype": objecttype,