diff --git a/lib/kmxgit/git_manager.ex b/lib/kmxgit/git_manager.ex
index a33e479..cddabd7 100644
--- a/lib/kmxgit/git_manager.ex
+++ b/lib/kmxgit/git_manager.ex
@@ -77,6 +77,12 @@ defmodule Kmxgit.GitManager do
end
end
+ def public_access(repo) do
+ dir = git_dir(repo)
+ export = "#{dir}/git-daemon-export-ok"
+ File.exists?(export)
+ end
+
def public_access(repo, true) do
dir = git_dir(repo)
export = "#{dir}/git-daemon-export-ok"
diff --git a/lib/kmxgit_web/controllers/admin/repository_controller.ex b/lib/kmxgit_web/controllers/admin/repository_controller.ex
index 3e7c2f0..1b79585 100644
--- a/lib/kmxgit_web/controllers/admin/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/repository_controller.ex
@@ -102,10 +102,12 @@ defmodule KmxgitWeb.Admin.RepositoryController do
def show(conn, params) do
repo = RepositoryManager.get_repository!(params["id"])
+ public_access = RepositoryManager.public_access(Repository.full_slug(repo))
|> RepositoryManager.put_disk_usage()
conn
|> assign(:members, Repository.members(repo))
|> assign(:repo, repo)
+ |> assign(:public_access, public_access)
|> render("show.html")
end
diff --git a/lib/kmxgit_web/templates/repository/form.html.heex b/lib/kmxgit_web/templates/repository/form.html.heex
index ccb2526..1802960 100644
--- a/lib/kmxgit_web/templates/repository/form.html.heex
+++ b/lib/kmxgit_web/templates/repository/form.html.heex
@@ -12,7 +12,7 @@
</div>
<div class="mb-3 form-check">
- <%= checkbox f, :public_access, class: "form-check-input" %>
+ <%= checkbox f, :public_access, value: @public_access, class: "form-check-input" %>
<%= label f, :public_access, gettext("Public access ?"), class: "form-check-label" %>
<%= error_tag f, :public_access %>
</div>
diff --git a/lib/kmxgit_web/templates/repository/show_properties.html.heex b/lib/kmxgit_web/templates/repository/show_properties.html.heex
index 92822af..e59c0f1 100644
--- a/lib/kmxgit_web/templates/repository/show_properties.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_properties.html.heex
@@ -5,7 +5,7 @@
</li>
<li class="list-group-item">
<table class="table properties">
- <%= if @repo.public_access do %>
+ <%= if @public_access do %>
<tr>
<th><%= gettext "Git HTTP" %></th>
<td><%= Repository.http_url(@repo) %></td>
@@ -18,7 +18,7 @@
<tr>
<th><%= gettext "Public access ?" %></th>
<td>
- <%= if @repo.public_access do %>
+ <%= if @public_access do %>
<%= gettext "public" %>
<% else %>
<%= gettext "private" %>