Use next commit in log continuation
Fix a bug where the first commit in the log after clicking "Next" is the same as the last commit on the previous page.
This commit is contained in:
parent
4f0a8ec086
commit
8249531f38
|
@ -528,13 +528,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()}
|
||||
|
@ -545,8 +547,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)
|
||||
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue