From 5bb964fe26f782a03a931c3be15f2420b8112727 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Nov 18 2015 13:30:09 +0000 Subject: Sometime the identified we get is a Tag, not a commit In which case we need to get the commit of the tag --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index bc7a063..1b66849 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -377,6 +377,9 @@ def view_file(repo, identifier, filename, username=None): commit = repo_obj[repo_obj.head.target] branchname = 'master' + if isinstance(commit, pygit2.Tag): + commit = commit.get_object() + if commit and not isinstance(commit, pygit2.Blob): content = __get_file_in_tree( repo_obj, commit.tree, filename.split('/'), bail_on_tree=True) @@ -474,6 +477,9 @@ def view_raw_file(repo, identifier, filename=None, username=None): if not commit: flask.abort(400, 'Commit %s not found' % (identifier)) + if isinstance(commit, pygit2.Tag): + commit = commit.get_object() + mimetype = None encoding = None if filename: