From 98040e0efc6e8fd0ed15a844d009e6b547b28c14 Mon Sep 17 00:00:00 2001 From: Martin Vahlensieck Date: Sat, 29 May 2021 18:38:35 +0200 Subject: [PATCH] Fix logic for displaying "next" link on log page Fetch one more commit from get_log and only display a "next" link if it exists. The current logic checks whether the last commit in the list has a parent. This doesn't work if the log is shown for a path, because when the first commit for the path is not the initial commit it has a parent, but there are no more log entries for the path. The parameter name for the template is copied from hg.sr.ht which solves this problem with an additional return parameter from get_log. --- gitsrht/blueprints/repo.py | 6 ++++-- gitsrht/templates/log.html | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index b3d96e6..31bc848 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -418,15 +418,17 @@ def log(owner, repo, ref, path): if not commit: abort(404) - commits = get_log(git_repo, commit, path) + commits = get_log(git_repo, commit, path, 21) entry = None if path and commit.tree and path in commit.tree: entry = commit.tree[path] + has_more = commits and len(commits) == 21 return render_template("log.html", view="log", owner=owner, repo=repo, ref=ref, path=path.split("/"), - commits=commits, refs=refs, entry=entry, pygit2=pygit2) + commits=commits[:20], refs=refs, entry=entry, pygit2=pygit2, + has_more=has_more) @repo.route("///log/rss.xml", defaults={"ref": None}) diff --git a/gitsrht/templates/log.html b/gitsrht/templates/log.html index 11ec243..4f94073 100644 --- a/gitsrht/templates/log.html +++ b/gitsrht/templates/log.html @@ -47,7 +47,7 @@ {% endfor %} - {% if commits and commits[-1].parents %} + {% if commits and has_more %}