Commit 628c161a29ce0c3a6a4219db7337c0bf74084568

Thomas de Grivel 2022-01-14T13:51:32

git diff

diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index 5347bca..dfab6a2 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -337,13 +337,15 @@ defmodule KmxgitWeb.RepositoryController do
     |> assign(:repo, repo)
     |> render("commit.html")
   end
-  defp show_op(conn, :diff, %{branch: branch, org: org, path: path, repo: repo}) do
-    {:ok, diff} = GitManager.diff(Repository.full_slug(repo), branch, path)
+  defp show_op(conn, :diff, %{from: from, org: org, repo: repo, to: to}) do
+    {:ok, diff} = GitManager.diff(Repository.full_slug(repo), from, to)
     diff_html = Pygmentize.html(diff, "diff.patch")
     conn
     |> assign_current_organisation(org)
     |> assign(:current_repository, repo)
+    |> assign(:diff_from, from)
     |> assign(:diff_html, diff_html)
+    |> assign(:diff_to, to)
     |> assign(:repo, repo)
     |> render("diff.html")
   end
diff --git a/lib/kmxgit_web/templates/repository/diff.html.heex b/lib/kmxgit_web/templates/repository/diff.html.heex
new file mode 100644
index 0000000..afa860f
--- /dev/null
+++ b/lib/kmxgit_web/templates/repository/diff.html.heex
@@ -0,0 +1,21 @@
+<div class="container-fluid">
+  <div class="row">
+    <div class="col col-12">
+      <%= render("show_title.html", assigns) %>
+      <h2>
+        <%= gettext("Diff") %>
+        <%= gettext("from") %>
+        <%= @diff_from %>
+        <%= gettext("to") %>
+        <%= @diff_to %>
+      </h2>
+    </div>
+  </div>
+  <div class="row">
+    <hr/>
+    <div class="col col-12">
+      <%= raw @diff_html %>
+      <hr/>
+    </div>
+  </div>
+</div>