diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index 30599a8..35c7807 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -155,12 +155,13 @@ defmodule KmxgitWeb.RepositoryController do
path2 = (path1 ++ rest1)
|> Enum.reject(&(!&1 || &1 == ""))
|> Enum.join("/")
- {op, branch, path2}
+ path3 = if path2 != "", do: path2
+ {op, branch, path3}
else
- {nil, nil, ""}
+ {nil, nil, nil}
end
else
- {nil, nil, ""}
+ {nil, nil, nil}
end
end
@@ -187,7 +188,7 @@ defmodule KmxgitWeb.RepositoryController do
{:ok, branches} ->
branches = branches
|> Enum.map(fn branch ->
- url = Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo) ++ ["_#{op}", branch] ++ (if path, do: String.split(path, "/")))
+ url = Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo) ++ ["_#{op || :tree}", branch] ++ (if path, do: String.split(path, "/"), else: []))
{branch, url}
end)
%{git | branches: branches}
@@ -199,7 +200,7 @@ defmodule KmxgitWeb.RepositoryController do
end
defp git_put_files(git = %{valid: true}, repo, branch, subdir, conn) do
- case GitManager.files(Repository.full_slug(repo), branch, subdir) do
+ case GitManager.files(Repository.full_slug(repo), branch, subdir || "") do
{:ok, []} -> git
{:ok, files} ->
files = files
@@ -315,7 +316,7 @@ defmodule KmxgitWeb.RepositoryController do
log = git_log(git, repo, branch, path)
conn
|> assign(:branch, branch)
- |> assign(:branch_url, Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo, ["_log", branch] ++ (if path, do: String.split(path, "/")))))
+ |> assign(:branch_url, Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo, ["_log", branch] ++ (if path, do: String.split(path, "/"), else: []))))
|> assign_current_organisation(org)
|> assign(:current_repository, repo)
|> assign(:git, git)
@@ -327,7 +328,7 @@ defmodule KmxgitWeb.RepositoryController do
defp show_op(conn, :tree, branch, git, org, path, repo, user) do
conn
|> assign(:branch, branch)
- |> assign(:branch_url, Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo, if branch do ["_tree", branch] else [] end)))
+ |> assign(:branch_url, Routes.repository_path(conn, :show, Repository.owner_slug(repo), Repository.splat(repo, ["_tree", branch] ++ (if path, do: String.split(path, "/"), else: []))))
|> assign_current_organisation(org)
|> assign(:current_repository, repo)
|> assign(:git, git)
diff --git a/lib/kmxgit_web/templates/repository/log.html.heex b/lib/kmxgit_web/templates/repository/log.html.heex
index 9bc81a6..1417b33 100644
--- a/lib/kmxgit_web/templates/repository/log.html.heex
+++ b/lib/kmxgit_web/templates/repository/log.html.heex
@@ -8,7 +8,7 @@
<div class="row">
<div class="col">
- <%= if @path && @path != "" do %>
+ <%= if @path do %>
<hr/>
<h2><%= link @path, to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_tree", @branch] ++ String.split(@path, "/"))) %></h2>
<% end %>
diff --git a/lib/kmxgit_web/templates/repository/show.html.heex b/lib/kmxgit_web/templates/repository/show.html.heex
index a01615c..27c38ae 100644
--- a/lib/kmxgit_web/templates/repository/show.html.heex
+++ b/lib/kmxgit_web/templates/repository/show.html.heex
@@ -11,8 +11,10 @@
<div class="row">
<div class="col col-12 col-md-7">
- <hr/>
- <h2><%= @path %></h2>
+ <%= if @path do %>
+ <hr/>
+ <h2><%= @path %></h2>
+ <% end %>
<hr/>
<%= render("show_branch.html", assigns) %>
diff --git a/lib/kmxgit_web/templates/repository/show_commit_message.html.heex b/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
index 7a1ca8c..f574610 100644
--- a/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
@@ -1,6 +1,6 @@
<div class="log1">
<span class="hash">
- <%= link String.slice(@git.log1.hash, 0..8), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_log", @branch] ++ (if @path, do: @path |> String.split("/")))) <> "##{@git.log1.hash}" %>
+ <%= link String.slice(@git.log1.hash, 0..8), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_log", @branch] ++ (if @path, do: String.split(@path, "/"), else: []))) <> "##{@git.log1.hash}" %>
</span>
<span class="author">
<%= @git.log1.author %>