Commit af0cb61a68a00dfd1c5e263cb0818ae19b05e9c8

Thomas de Grivel 2022-01-15T09:59:34

git diff

diff --git a/lib/kmxgit_web/templates/repository/commit.html.heex b/lib/kmxgit_web/templates/repository/commit.html.heex
index ea49b5a..543bb17 100644
--- a/lib/kmxgit_web/templates/repository/commit.html.heex
+++ b/lib/kmxgit_web/templates/repository/commit.html.heex
@@ -23,6 +23,7 @@
           <th><%= gettext("Actions") %></th>
           <td>
             <%= link gettext("Browse"), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_tree", @commit.hash])), class: "btn btn-primary" %>
+            <%= link gettext("Diff"), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_diff", @commit.hash, "master"])), class: "btn btn-primary" %>
           </td>
         </tr>
         <tr>
diff --git a/lib/kmxgit_web/templates/repository/show_actions.html.heex b/lib/kmxgit_web/templates/repository/show_actions.html.heex
index dcc7343..25ca1ac 100644
--- a/lib/kmxgit_web/templates/repository/show_actions.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_actions.html.heex
@@ -6,3 +6,6 @@
 <%= if @current_user do %>
   <%= link gettext("Fork"), to: Routes.repository_path(@conn, :fork, Repository.owner_slug(@repo), Repository.splat(@repo)), class: "btn btn-primary" %>
 <% end %>
+<%= if (@branch != "master") do %>
+  <%= link gettext("Diff"), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_diff", @branch, "master"])), class: "btn btn-primary" %>
+<% end %>
diff --git a/lib/kmxgit_web/templates/repository/show_branch.html.heex b/lib/kmxgit_web/templates/repository/show_branch.html.heex
index 9b82325..6319117 100644
--- a/lib/kmxgit_web/templates/repository/show_branch.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_branch.html.heex
@@ -1,19 +1,21 @@
 <%= if @branch do %>
   <hr/>
   <%= if Enum.find(@git.branches, fn {name, _} -> name == @branch end) do %>
-    <%= gettext("Branch") %>
-    <%= select :repository, :branch, @git.branches, selected: @branch_url, onchange: "javascript:document.location = this.value;" %>
+    <p>
+      <%= gettext("Branch") %>
+      <%= select :repository, :branch, @git.branches, selected: @branch_url, onchange: "javascript:document.location = this.value;" %>
+    </p>
   <% else %>
     <%= if String.length(@branch) == 40 do %>
       <h2>
         <%= gettext("Commit") %>
         <%= @branch %>
       </h2>
-    <% else %>
+     <% else %>
       <h2>
         <%= gettext("Tag") %>
         <%= @branch %>
       </h2>
-    <% end %>
+     <% end %>
   <% end %>
 <% end %>