~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] Use next commit in log continuation

Details
Message ID
<20230818151935.58205-1-greg@gpanders.com>
DKIM signature
missing
Download raw message
Patch: +8 -6
Fix a bug where the first commit in the log after clicking "Next" is the
same as the last commit on the previous page.
---
Rebased on master. Also slightly reworded the commit message and tweaked
the implementation from v1.

 gitsrht/blueprints/repo.py | 10 ++++++----
 gitsrht/templates/log.html |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py
index ef379b2..f2f3fc4 100644
--- a/gitsrht/blueprints/repo.py
+++ b/gitsrht/blueprints/repo.py
@@ -524,13 +524,15 @@ def log(owner, repo, ref, path):
        if not commit:
            abort(404)

        commits = get_log(git_repo, commit, path, 21)
        num_commits = 20
        commits = get_log(git_repo, commit, path, num_commits + 1)

        entry = None
        if path and commit.tree and path in commit.tree:
            entry = commit.tree[path]

        has_more = commits and len(commits) == 21
        has_more = commits and len(commits) == num_commits + 1
        next_commit = commits[-1] if has_more else None

        author_emails = set((commit.author.email for commit in commits[:20]))
        authors = {user.email:user for user in User.query.filter(User.email.in_(author_emails)).all()}
@@ -541,8 +543,8 @@ def log(owner, repo, ref, path):

        return render_template("log.html", view="log",
                owner=owner, repo=repo, ref=ref, path=path.split("/"),
                commits=commits[:20], refs=refs, entry=entry, pygit2=pygit2,
                has_more=has_more, authors=authors,
                commits=commits[:num_commits], refs=refs, entry=entry, pygit2=pygit2,
                next_commit=next_commit, authors=authors,
                license_exists=license_exists, licenses=licenses)


diff --git a/gitsrht/templates/log.html b/gitsrht/templates/log.html
index de10c28..dbe4f37 100644
--- a/gitsrht/templates/log.html
+++ b/gitsrht/templates/log.html
@@ -47,7 +47,7 @@
        </div>
        {% endfor %}
      </div>
      {% if commits and has_more %}
      {% if next_commit %}
      <a
        class="pull-right btn btn-primary"
        href="{{url_for("repo.log",
@@ -55,7 +55,7 @@
          repo=repo.name,
          ref=ref,
          path=full_path,
        )}}?from={{commits[-1].id}}"
        )}}?from={{next_commit.id}}"
      >Next {{icon("caret-right")}}</a>
      {% endif %}
    </div>
-- 
2.41.0
Details
Message ID
<CXFGRVO79V9T.19LWZ1LWPKGZT@taiga>
In-Reply-To
<20230818151935.58205-1-greg@gpanders.com> (view parent)
DKIM signature
missing
Download raw message
Thanks!

To git@git.sr.ht:~sircmpwn/git.sr.ht
   4f0a8ec..4278f32  master -> master
Reply to thread Export thread (mbox)