Commit 21d7a2038a07946e3e046cf432dc4894f76ea5cc

Thomas de Grivel 2022-06-04T10:48:07

fix repository tag view

diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index 85f359d..e20a476 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -452,14 +452,16 @@ defmodule KmxgitWeb.RepositoryController do
       not_found(conn)
     end
   end
-  defp show_op(conn, :tag = op, %{tree: tree, git: git, org: org, repo: repo}) do
+  defp show_op(conn, :tag = op, %{tree: tree, git: git, org: org, path: path, repo: repo}) do
     git = git
+    |> git_put_log1(repo, tree, path)
     |> git_put_tags(repo, conn, op, nil)
-    tag = Enum.find(git.tags, fn tag -> tag.tag == tree end)
+    tag = Enum.find(git.tags, fn tag -> tag == tree end)
     if tag do
       conn
       |> assign_current_organisation(org)
       |> assign(:current_repository, repo)
+      |> assign(:git, git)
       |> assign(:path, nil)
       |> assign(:repo, repo)
       |> assign(:tag, tag)
diff --git a/lib/kmxgit_web/templates/repository/tag.html.heex b/lib/kmxgit_web/templates/repository/tag.html.heex
index 1851ab0..509a229 100644
--- a/lib/kmxgit_web/templates/repository/tag.html.heex
+++ b/lib/kmxgit_web/templates/repository/tag.html.heex
@@ -11,14 +11,14 @@
       <hr/>
       <h2>
         <%= gettext("Tag") %>
-        <%= @tag.tag %>
+        <%= @tag %>
       </h2>
 
       <p>
-        <%= @tag.message %>
+        <%= @git.log1.message %>
       </p>
 
-      <%= link gettext("Browse"), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_tree", @tag.tag])), class: "btn btn-primary" %>
+      <%= link gettext("Browse"), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_tree", @tag])), class: "btn btn-primary" %>
     </div>
 
     <div class="col col-12 col-md-5">
@@ -26,15 +26,16 @@
       <table class="table">
         <tr>
           <th><%= gettext("Commit") %></th>
-          <td><%= link (@tag.hash |> String.slice(0..7)), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_commit", @tag.hash])) %></td>
+          <td><%= link (@git.log1.hash |> String.slice(0..7)), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_commit", @git.log1.hash])) %></td>
         </tr>
         <tr>
           <th><%= gettext("Author") %></th>
-          <td><%= @tag.author %></td>
+          <td>  <%= render(KmxgitWeb.UserView, "avatar.html", conn: @conn, email: @git.log1.author_email, size: 48, title: @git.log1.author, class: "commit-avatar") %>
+</td>
         </tr>
         <tr>
           <th><%= gettext("Date") %></th>
-          <td><%= @tag.date |> String.replace("T", " ") |> String.replace("+", " +") %></td>
+          <td><%= NaiveDateTime.add(~N[1970-01-01 00:00:00], @git.log1.date) %></td>
         </tr>
       </table>
     </div>