hovercards: handle empty repository

This commit is contained in:
Marcin Kuzminski 2019-12-09 12:53:12 +01:00
parent e198f35a29
commit 9bf9f2f76d

View file

@ -34,7 +34,7 @@ from rhodecode.lib.codeblocks import filenode_as_lines_tokens
from rhodecode.lib.index import searcher_from_config
from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int
from rhodecode.lib.ext_json import json
from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError
from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError, EmptyRepositoryError
from rhodecode.lib.vcs.nodes import FileNode
from rhodecode.model.db import (
func, true, or_, case, in_filter_generator, Repository, RepoGroup, User, UserGroup, PullRequest)
@ -102,8 +102,9 @@ class HoverCardsRepoView(RepoAppView):
commit_id = self.request.matchdict['commit_id']
pre_load = ['author', 'branch', 'date', 'message']
try:
c.commit = self.rhodecode_vcs_repo.get_commit(commit_id=commit_id, pre_load=pre_load)
except CommitDoesNotExistError:
c.commit = self.rhodecode_vcs_repo.get_commit(
commit_id=commit_id, pre_load=pre_load)
except (CommitDoesNotExistError, EmptyRepositoryError):
raise HTTPNotFound()
return self._get_template_context(c)