~edwargix/git.sr.ht

98040e0efc6e8fd0ed15a844d009e6b547b28c14 — Martin Vahlensieck 3 years ago 5cb8a00
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.
2 files changed, 5 insertions(+), 3 deletions(-)

M gitsrht/blueprints/repo.py
M gitsrht/templates/log.html
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +4 -2
@@ 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("/<owner>/<repo>/log/rss.xml", defaults={"ref": None})

M gitsrht/templates/log.html => gitsrht/templates/log.html +1 -1
@@ 47,7 47,7 @@
        </div>
        {% endfor %}
      </div>
      {% if commits and commits[-1].parents %}
      {% if commits and has_more %}
      <a
        class="pull-right btn btn-primary"
        href="{{url_for("repo.log",