From 66b80e713c58cc2a177bc16d779af5bea88c662f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 03 2017 16:52:56 +0000 Subject: Fix if the identifier provided is one of a blob instead of a commit Currently if the user provide the hash of a blob instead of the one of a commit, we simply crash since the objects are different. With this commit, we will raise a 404 error instead of a 500 error. Fixes an error reported by email Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index f4fa534..499b9c5 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -743,6 +743,9 @@ def view_commit(repo, commitid, username=None, namespace=None): if commit is None: flask.abort(404, 'Commit not found') + if isinstance(commit, pygit2.Blob): + flask.abort(404, 'Commit not found') + if commit.parents: diff = repo_obj.diff(commit.parents[0], commit) else: