diff --git a/README.md b/README.md
index 4b1b79d..5a5ca1a 100644
--- a/README.md
+++ b/README.md
@@ -84,9 +84,10 @@ location ~ ^(.*/info/refs|.*/git-upload-pack)$ {
- Github
- Gitlab ?
- Git features
- - Diff
- - Log
- - Tags (releases)
+ - diff
+ - DONE log
+ - DONE tags
+ - Releases (tags with db info)
# Copyright
diff --git a/lib/kmxgit/git_manager.ex b/lib/kmxgit/git_manager.ex
index 606eea7..0aba0d2 100644
--- a/lib/kmxgit/git_manager.ex
+++ b/lib/kmxgit/git_manager.ex
@@ -249,4 +249,26 @@ defmodule Kmxgit.GitManager do
_ -> {:error, out}
end
end
+
+ def tags(repo) do
+ dir = git_dir(repo)
+ {out, status} = System.cmd("git", ["-C", dir, "tag", "-l"], stderr_to_stdout: true)
+ case status do
+ 0 ->
+ tags = out
+ |> String.split("\n")
+ |> Enum.filter(& &1 && &1 != "")
+ |> Enum.map(& tag_info(repo, &1))
+
+ {:ok, tags}
+ _ ->
+ {:error, out}
+ end
+ end
+
+ def tag_info(repo, tag) do
+ {:ok, commit} = log1(repo, tag)
+ commit
+ |> Map.put(:tag, tag)
+ end
end
diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index ec0ddc9..6704ab0 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -143,6 +143,7 @@ defmodule KmxgitWeb.RepositoryController do
"_blob" -> :blob
"_commit" -> :commit
"_log" -> :log
+ "_tag" -> :tag
"_tree" -> :tree
x ->
IO.puts "Unknown operation #{x}"
@@ -177,12 +178,14 @@ defmodule KmxgitWeb.RepositoryController do
log1: nil,
readme: [],
status: "",
+ tags: [],
valid: true}
|> git_put_branches(repo, conn, op, path)
|> git_put_files(repo, branch, path, conn)
|> git_put_content(repo, path)
|> git_put_readme(repo)
|> git_put_log1(repo, branch, path)
+ |> git_put_tags(repo)
end
defp git_put_branches(git = %{valid: true}, repo, conn, op, path) do
@@ -286,6 +289,11 @@ defmodule KmxgitWeb.RepositoryController do
%{git | log1: log1}
end
+ defp git_put_tags(git, repo) do
+ {:ok, tags} = GitManager.tags(Repository.full_slug(repo))
+ %{git | tags: tags}
+ end
+
defp git_log(repo, branch, path) do
slug = Repository.full_slug(repo)
{:ok, log} = if path do
@@ -327,6 +335,15 @@ defmodule KmxgitWeb.RepositoryController do
|> assign(:repo, repo)
|> render("log.html")
end
+ defp show_op(conn, :tag, branch, git, org, _path, repo, _user) do
+ tag = Enum.find(git.tags, fn tag -> tag.tag == branch end)
+ conn
+ |> assign_current_organisation(org)
+ |> assign(:current_repository, repo)
+ |> assign(:repo, repo)
+ |> assign(:tag, tag)
+ |> render("tag.html")
+ end
defp show_op(conn, :tree, branch, git, org, path, repo, user) do
conn
|> assign(:branch, branch)
diff --git a/lib/kmxgit_web/templates/repository/commit.html.heex b/lib/kmxgit_web/templates/repository/commit.html.heex
index 7b791ad..fdc35a0 100644
--- a/lib/kmxgit_web/templates/repository/commit.html.heex
+++ b/lib/kmxgit_web/templates/repository/commit.html.heex
@@ -1,26 +1,32 @@
<div class="container-fluid">
-
<div class="row">
- <%= render("show_title.html", assigns) %>
+ <div class="col col-12">
+ <%= render("show_title.html", assigns) %>
+ <h2>
+ <%= gettext("Commit") %>
+ <%= @commit.hash %>
+ </h2>
+ </div>
</div>
-
<div class="row">
<hr/>
- <h2>
- <%= gettext("Commit") %>
- <%= @commit.hash %>
- </h2>
-
- <div class="commit">
- <div class="author">
- <%= @commit.author %>
- </div>
- <div class="date">
- <%= @commit.date |> String.replace("T", " ") |> String.replace("+", " +") %>
- </div>
- <div class="message" %>
+ <div class="col col-12 col-md-7">
+ <p>
<%= @commit.message %>
- </div>
+ </p>
+ <hr/>
+ </div>
+ <div class="col col-12 col-md-5">
+ <table class="table">
+ <tr>
+ <th><%= gettext("Author") %></th>
+ <td><%= @commit.author %></td>
+ </tr>
+ <tr>
+ <th><%= gettext("Date") %></th>
+ <td><%= @commit.date |> String.replace("T", " ") |> String.replace("+", " +") %></td>
+ </tr>
+ </table>
</div>
</div>
</div>
diff --git a/lib/kmxgit_web/templates/repository/log.html.heex b/lib/kmxgit_web/templates/repository/log.html.heex
index 1417b33..ce0e1f1 100644
--- a/lib/kmxgit_web/templates/repository/log.html.heex
+++ b/lib/kmxgit_web/templates/repository/log.html.heex
@@ -32,7 +32,7 @@
<%= for commit <- @log do %>
<tr class="commit">
<td class="hash">
- <%= link String.slice(commit.hash, 0..8), 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", @git.log1.hash])) %>
</td>
<td class="author">
<%= commit.author %>
diff --git a/lib/kmxgit_web/templates/repository/show.html.heex b/lib/kmxgit_web/templates/repository/show.html.heex
index 27c38ae..a8b1d9a 100644
--- a/lib/kmxgit_web/templates/repository/show.html.heex
+++ b/lib/kmxgit_web/templates/repository/show.html.heex
@@ -1,10 +1,10 @@
<div class="container-fluid">
<div class="row">
- <div class="col col-12 col-sm-7">
+ <div class="col col-12 col-md-7">
<%= render("show_title.html", assigns) %>
</div>
- <div class="col col-12 col-sm-5">
+ <div class="col col-12 col-md-5">
<%= render("show_actions.html", assigns) %>
</div>
</div>
diff --git a/lib/kmxgit_web/templates/repository/show_properties.html.heex b/lib/kmxgit_web/templates/repository/show_properties.html.heex
index 9ad4506..c0b4312 100644
--- a/lib/kmxgit_web/templates/repository/show_properties.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_properties.html.heex
@@ -50,4 +50,18 @@
</ul>
</td>
</tr>
+ <%= if @git.tags do %>
+ <tr>
+ <th><%= gettext("Tags") %></th>
+ <td>
+ <ul>
+ <%= for tag <- @git.tags |> Enum.reverse() do %>
+ <li>
+ <%= link tag.tag, to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_tag", tag.tag])) %>
+ </li>
+ <% end %>
+ </ul>
+ </td>
+ </tr>
+ <% end %>
</table>
diff --git a/lib/kmxgit_web/templates/repository/tag.html.heex b/lib/kmxgit_web/templates/repository/tag.html.heex
new file mode 100644
index 0000000..9f031c5
--- /dev/null
+++ b/lib/kmxgit_web/templates/repository/tag.html.heex
@@ -0,0 +1,40 @@
+<div class="container-fluid">
+
+ <div class="row">
+ <div class="col col-12 col-md-7">
+ <%= render("show_title.html", assigns) %>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="col col-12 col-md-7">
+ <hr/>
+ <h2>
+ <%= gettext("Tag") %>
+ <%= @tag.tag %>
+ </h2>
+
+ <div class="message" %>
+ <%= @tag.message %>
+ </div>
+ </div>
+
+ <div class="col col-12 col-md-5">
+ <hr/>
+ <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>
+ </tr>
+ <tr>
+ <th><%= gettext("Author") %></th>
+ <td><%= @tag.author %></td>
+ </tr>
+ <tr>
+ <th><%= gettext("Date") %></th>
+ <td><%= @tag.date |> String.replace("T", " ") |> String.replace("+", " +") %></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+</div>