M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +5 -2
@@ 12,7 12,7 @@ from gitsrht.editorconfig import EditorConfig
from gitsrht.git import Repository as GitRepository, commit_time, annotate_tree
from gitsrht.git import diffstat, get_log, diff_for_commit, strip_pgp_signature
from gitsrht.rss import generate_feed
-from gitsrht.types import Artifact
+from gitsrht.types import Artifact, User
from io import BytesIO
from jinja2 import Markup
from jinja2.utils import url_quote, escape
@@ 484,10 484,13 @@ def log(owner, repo, ref, path):
entry = commit.tree[path]
has_more = commits and len(commits) == 21
+
+ 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()}
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)
+ has_more=has_more, authors=authors)
@repo.route("/<owner>/<repo>/log/rss.xml", defaults={"ref": None})
M gitsrht/templates/log.html => gitsrht/templates/log.html +1 -1
@@ 39,7 39,7 @@
{% set full_path = path_join(*path) %}
{% for c in commits %}
<div class="event">
- {{ utils.commit_event(repo, c, True, refs, path=full_path) }}
+ {{ utils.commit_event(repo, c, True, refs, path=full_path, lookup=authors.get) }}
</div>
{% else %}
<div class="event">
M gitsrht/templates/utils.html => gitsrht/templates/utils.html +3 -2
@@ 73,7 73,8 @@ endif %}{% endfor %}
{% macro commit_event(repo, c,
full_body=False, refs={}, full_id=False, diff=None, href=None,
- parents=False, skip_body=False, target_blank=False, path=None) %}
+ parents=False, skip_body=False, target_blank=False, path=None,
+ lookup=lookup_user) %}
<div>
{% if full_id %}
{{c.id.hex}}
@@ 92,7 93,7 @@ endif %}{% endfor %}
>{{c.id.hex[:8]}}</a>
{% endif %}
—
- {% set author_user = lookup_user(c.author.email) %}
+ {% set author_user = lookup(c.author.email) %}
{% if author_user %}
<a href="{{url_for("public.user_index",
username=author_user.username)}}">{{c.author.name}}</a>