~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
5 4

[PATCH git.sr.ht] Add mailmap support

Details
Message ID
<20240129194317.830477-1-aoife@enby.space>
DKIM signature
pass
Download raw message
Patch: +10 -5
---
 gitsrht/app.py               | 5 +++--
 gitsrht/git.py               | 6 +++++-
 gitsrht/templates/utils.html | 4 ++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gitsrht/app.py b/gitsrht/app.py
index eaae395..f1c46c0 100644
--- a/gitsrht/app.py
+++ b/gitsrht/app.py
@@ -3,7 +3,7 @@ import os
import stat
from functools import lru_cache
from gitsrht import urls
from gitsrht.git import commit_time, commit_links, trim_commit, signature_time
from gitsrht.git import commit_time, commit_links, trim_commit, signature_time, canonical_user
from gitsrht.service import oauth_service, webhooks_notify
from gitsrht.types import User
from srht.config import cfg
@@ -72,7 +72,8 @@ class GitApp(SrhtFlask):
                "path_join": os.path.join,
                "stat": stat,
                "trim_commit": trim_commit,
                "lookup_user": self.lookup_user
                "lookup_user": self.lookup_user,
                "canonical_user": canonical_user
            }

        choices = [self.jinja_loader, FileSystemLoader(os.path.join(
diff --git a/gitsrht/git.py b/gitsrht/git.py
index 3c67241..25c363b 100644
--- a/gitsrht/git.py
+++ b/gitsrht/git.py
@@ -1,6 +1,6 @@
from collections import deque
from datetime import datetime, timedelta, timezone
from pygit2 import Repository as GitRepository, Tag
from pygit2 import Repository as GitRepository, Tag, Mailmap
from markupsafe import Markup, escape
from stat import filemode
import pygit2
@@ -229,3 +229,7 @@ def diffstat(diff, anchor=""):
    for delta, patch in zip(diff.deltas, diff):
        stat += _diffstat_line(delta, patch, anchor)
    return stat

def canonical_user(author, repo):
    mailmap = Mailmap.from_repository(repo.git_repo)
    return mailmap.resolve(author.name, author.email)
diff --git a/gitsrht/templates/utils.html b/gitsrht/templates/utils.html
index 3b9e2d5..794014e 100644
--- a/gitsrht/templates/utils.html
+++ b/gitsrht/templates/utils.html
@@ -102,9 +102,9 @@ endif %}{% endfor %}
  {% 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>
    username=author_user.username)}}">{{canonical_user(c.author, repo)[0]}}</a>
  {% else %}
  {{c.author.name}}
  {{canonical_user(c.author, repo)[0]}}
  {% endif %}
  <small class="pull-right">
    <a
-- 
2.43.0

[git.sr.ht/patches] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CYRG5SS9NQLT.1SWJ928IJIYYM@fra01>
In-Reply-To
<20240129194317.830477-1-aoife@enby.space> (view parent)
DKIM signature
missing
Download raw message
git.sr.ht/patches: FAILED in 2m12s

[Add mailmap support][0] from [aoife cassidy][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/49003
[1]: aoife@enby.space

✗ #1139849 FAILED  git.sr.ht/patches/archlinux.yml https://builds.sr.ht/~sircmpwn/job/1139849
✓ #1139848 SUCCESS git.sr.ht/patches/alpine.yml    https://builds.sr.ht/~sircmpwn/job/1139848
✓ #1139850 SUCCESS git.sr.ht/patches/debian.yml    https://builds.sr.ht/~sircmpwn/job/1139850
Details
Message ID
<742385d2-18e9-46be-9172-3887b3452259@enby.space>
In-Reply-To
<20240129194317.830477-1-aoife@enby.space> (view parent)
DKIM signature
pass
Download raw message
i did notice that there is a patch[1] that was applied over a year ago 
that adds the same thing, but from grepping the code i don't see any of it.

[1]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/36542
Details
Message ID
<cj-GV_p5ktB__TdtabLUCKkZuTUZRjWn2MZNYN1MZJFAXLkZW3axzLLKG5SNovYiVhIcv9Jcl2xKyzb8sMkKlkBonfJm8SCh9Cdo5rkiMiA=@emersion.fr>
In-Reply-To
<742385d2-18e9-46be-9172-3887b3452259@enby.space> (view parent)
DKIM signature
pass
Download raw message
Could this be the following?
https://git.sr.ht/~sircmpwn/git.sr.ht/commit/cd790c9bedcd6c113d1a33192a56530f4ebecb90
Details
Message ID
<b5d2865b-c550-4966-b7c1-daec94c4fcd8@enby.space>
In-Reply-To
<cj-GV_p5ktB__TdtabLUCKkZuTUZRjWn2MZNYN1MZJFAXLkZW3axzLLKG5SNovYiVhIcv9Jcl2xKyzb8sMkKlkBonfJm8SCh9Cdo5rkiMiA=@emersion.fr> (view parent)
DKIM signature
pass
Download raw message
aha. well, this commit has a pretty different implementation of the
mailmap support, and i don't know what the oversight or backtrace are.
so maybe this one works? if i can reproduce the issue i can try to get
it fixed.
Details
Message ID
<CYSQEFKVXZSV.18KPOQWLMQ3ZG@taiga>
In-Reply-To
<b5d2865b-c550-4966-b7c1-daec94c4fcd8@enby.space> (view parent)
DKIM signature
pass
Download raw message
On Mon Jan 29, 2024 at 8:57 PM CET, aoife cassidy wrote:
> aha. well, this commit has a pretty different implementation of the
> mailmap support, and i don't know what the oversight or backtrace are.
> so maybe this one works? if i can reproduce the issue i can try to get
> it fixed.

If I recall correctly, there was a repository whose author writes
commits with an empty git user.email address (resulting in
"Full Name <>"):

https://git.sr.ht/~rj/sgr

This causes the following backtrace with the earlier patch:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/lib/python3.9/site-packages/gitsrht/blueprints/repo.py", line 156, in summary
    return render_template("summary.html", view="summary",
  File "/usr/lib/python3.9/site-packages/flask/templating.py", line 147, in render_template
    return _render(
  File "/usr/lib/python3.9/site-packages/flask/templating.py", line 128, in _render
    rv = template.render(context)
  File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/lib/python3.9/site-packages/gitsrht/templates/summary.html", line 2, in top-level template code
    {% import "utils.html" as utils with context %}
  File "/usr/lib/python3.9/site-packages/gitsrht/templates/repo.html", line 1, in top-level template code
    {% extends "layout.html" %}
  File "/usr/lib/python3.9/site-packages/srht/templates/layout.html", line 46, in top-level template code
    {% block body %}
  File "/usr/lib/python3.9/site-packages/gitsrht/templates/repo.html", line 102, in block 'body'
    {% block content %}{% endblock %}
  File "/usr/lib/python3.9/site-packages/gitsrht/templates/summary.html", line 38, in block 'content'
    {{ utils.commit_event(repo, c) }}
  File "/usr/lib/python3.9/site-packages/jinja2/runtime.py", line 828, in _invoke
    rv = self._func(*arguments)
  File "/usr/lib/python3.9/site-packages/gitsrht/templates/utils.html", line 96, in template
    {% set author = repo.author(c) %}
  File "/usr/lib/python3.9/site-packages/gitsrht/types/__init__.py", line 152, in author
    return self.git_repo.author(obj)
  File "/usr/lib/python3.9/site-packages/gitsrht/git.py", line 128, in author
    return self._mailmap.resolve_signature(sig)
ValueError: failed to parse signature - Signature cannot have an empty name or email
Reply to thread Export thread (mbox)