Commit cd2c6c8422d5fc69e1f7f1c544d78013a4a92b77

Thomas de Grivel 2022-01-26T00:20:55

fix git commands

diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index a66c4c5..24e0b50 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -356,6 +356,7 @@ defmodule KmxgitWeb.RepositoryController do
   end
   defp show_op(conn, :commit = op, %{git: git, org: org, path: path, repo: repo, tree: tree}) do
     git = git
+    |> git_put_log1(repo, tree, path)
     |> git_put_commit(repo, conn, op, tree, path)
     IO.inspect(git)
     diff = case GitManager.diff(Repository.full_slug(repo), "#{git.log1.hash}~1", git.log1.hash) do
@@ -370,10 +371,11 @@ defmodule KmxgitWeb.RepositoryController do
     |> assign(:current_repository, repo)
     |> assign(:diff_html, diff_html)
     |> assign(:diff_line_numbers, diff_line_numbers)
+    |> assign(:path, path)
     |> assign(:repo, repo)
     |> render("commit.html")
   end
-  defp show_op(conn, :diff, %{from: from, org: org, repo: repo, to: to}) do
+  defp show_op(conn, :diff, %{from: from, org: org, path: path, repo: repo, to: to}) do
     case GitManager.diff(Repository.full_slug(repo), from, to) do
       {:ok, diff} ->
         diff_html = Pygmentize.html(diff, "diff.patch")
@@ -386,6 +388,7 @@ defmodule KmxgitWeb.RepositoryController do
         |> assign(:diff_html, diff_html)
         |> assign(:diff_line_numbers, diff_line_numbers)
         |> assign(:diff_to, to)
+        |> assign(:path, path)
         |> assign(:repo, repo)
         |> render("diff.html")
       {:error, e} ->
@@ -394,8 +397,8 @@ defmodule KmxgitWeb.RepositoryController do
     end
   end
   defp show_op(conn, :log, %{tree: tree, git: git, org: org, path: path, repo: repo}) do
-    git = git
     log = git_log(repo, tree, path)
+    IO.inspect([:log, tree: tree, git: git, path: path, log: log])
     conn
     |> assign(:tree, tree)
     |> assign(:tree_url, Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo, ["_log", tree] ++ (if path, do: String.split(path, "/"), else: []))))
diff --git a/lib/kmxgit_web/templates/repository/log.html.heex b/lib/kmxgit_web/templates/repository/log.html.heex
index b02443b..6ad547f 100644
--- a/lib/kmxgit_web/templates/repository/log.html.heex
+++ b/lib/kmxgit_web/templates/repository/log.html.heex
@@ -34,7 +34,7 @@
                 <%= render(KmxgitWeb.UserView, "avatar.html", conn: @conn, email: commit.author_email, size: 48, title: commit.author, class: "") %>
               </td>
               <td class="hash">
-                <%= link String.slice(commit.hash, 0..7), id: commit.hash, to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_commit", @git.log1.hash])) %>
+                <%= link String.slice(commit.hash, 0..7), id: commit.hash, to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_commit", commit.hash])) %>
               </td>
               <td class="date">
                 <%= commit.date |> String.replace("T", " ") |> String.replace("+", " +") %>