Commit e8999ce5e223219d8f378f01f290e74821d30694

Thomas de Grivel 2022-01-22T11:25:48

gravatar in repository show tree commit message

diff --git a/lib/kmxgit/git_manager.ex b/lib/kmxgit/git_manager.ex
index 6b59ccc..71a3b3f 100644
--- a/lib/kmxgit/git_manager.ex
+++ b/lib/kmxgit/git_manager.ex
@@ -221,15 +221,15 @@ defmodule Kmxgit.GitManager do
 
   defp log_(repo, args) do
     dir = git_dir(repo)
-    args = ["-C", dir, "log", "--format=%H %aI \"%an\" %s"] ++ args
+    args = ["-C", dir, "log", "--format=%H %aI \"%an <%ae>\" %s"] ++ args
     {out, status} = System.cmd("git", args, stderr_to_stdout: true)
     case status do
       0 ->
         entries = out
         |> String.split("\n")
         |> Enum.map(fn line ->
-          case Regex.run(~r/^([^ ]+) ([^ ]+) "([^"]+)" (.*)$/, line) do
-            [_ , hash, date, author, msg] -> %{author: author, hash: hash, date: date, message: msg}
+          case Regex.run(~r/^([^ ]+) ([^ ]+) "(.+ <([^>]+)>)" (.*)$/, line) do
+            [_ , hash, date, author, email, msg] -> %{author: author, author_email: email, hash: hash, date: date, message: msg}
             _ -> nil
           end
         end)
diff --git a/lib/kmxgit_web/templates/repository/show_commit_message.html.heex b/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
index fc7add8..7bf2ce2 100644
--- a/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
@@ -3,7 +3,7 @@
     <%= link String.slice(@git.log1.hash, 0..8), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_log", @tree] ++ (if @path, do: String.split(@path, "/"), else: []))) <> "##{@git.log1.hash}" %>
   </span>
   <span class="author">
-    <%= @git.log1.author %>
+    <img src={Exgravatar.gravatar_url(@git.log1.author_email, s: 32)} alt={@git.log1.author} title={@git.log1.author} />
   </span>
   <span class="date">
     <%= @git.log1.date |> String.replace("T", " ") |> String.replace("+", " +") %>