changeset 7974:ae98ec548fd4

summary: handle repo like changelog does Show "There are no changesets yet" instead of relying on pager to silently eat EmptyRepositoryError. Use .get_changesets() instead of using c.db_repo_scm_instance directly.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 24 Nov 2019 02:22:27 +0100
parents ad8328c8ed40
children 3936f5cc4c58
files kallithea/controllers/summary.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/summary.py	Wed Nov 20 23:49:40 2019 +0100
+++ b/kallithea/controllers/summary.py	Sun Nov 24 02:22:27 2019 +0100
@@ -38,6 +38,7 @@
 from tg.i18n import ugettext as _
 from webob.exc import HTTPBadRequest
 
+import kallithea.lib.helpers as h
 from kallithea.config.conf import ALL_EXTS, ALL_READMES, LANGUAGES_EXTENSIONS_MAP
 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
 from kallithea.lib.base import BaseRepoController, jsonify, render
@@ -45,7 +46,7 @@
 from kallithea.lib.compat import json
 from kallithea.lib.markup_renderer import MarkupRenderer
 from kallithea.lib.page import RepoPage
-from kallithea.lib.utils2 import safe_int
+from kallithea.lib.utils2 import safe_int, safe_str
 from kallithea.lib.vcs.backends.base import EmptyChangeset
 from kallithea.lib.vcs.exceptions import ChangesetError, EmptyRepositoryError, NodeDoesNotExistError
 from kallithea.lib.vcs.nodes import FileNode
@@ -104,7 +105,11 @@
     def index(self, repo_name):
         p = safe_int(request.GET.get('page'), 1)
         size = safe_int(request.GET.get('size'), 10)
-        collection = c.db_repo_scm_instance
+        try:
+            collection = c.db_repo_scm_instance.get_changesets()
+        except EmptyRepositoryError as e:
+            h.flash(safe_str(e), category='warning')
+            collection = []
         c.cs_pagination = RepoPage(collection, page=p, items_per_page=size)
         page_revisions = [x.raw_id for x in list(c.cs_pagination)]
         c.cs_comments = c.db_repo.get_comments(page_revisions)