gitweb: Fix deleting last repo disables app

GitWeb requires authenticated access if there are no public
repositories left.

1. Create a public repository
2. Delete the repository (i.e. delete the last/only repository)
3. GitWeb app shows as disabled, but is still usable
4. If another repository is created, the app becomes enabled again

Not considering the component GitwebWebserverAuth when determining
whether the app is enabled or disabled.

This commit fixes the status shown in the configuration page, but keeps
the authentication requirement if there are no public repositories.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Joseph Nuthalapati authored and Veiko Aasa committed 2026-01-12 11:10:14 +02:00
1 parent 54e0ead0e0
commit 958ac2e0a5
1 file changed
+3 -10
+3 -10
View File
@@ -109,14 +109,14 @@ class GitwebApp(app_module.App):
def _enable_public_access(self):
"""Allow Gitweb app to be accessed by anyone with access."""
if self.auth_webserver.is_conf_enabled():
if self.is_enabled():
self.auth_webserver.disable()
self.set_shortcut_login_required(False)
def _disable_public_access(self):
"""Allow Gitweb app to be accessed by logged-in users only."""
if self.is_enabled() and not self.auth_webserver.is_conf_enabled():
if self.is_enabled():
self.auth_webserver.enable()
self.set_shortcut_login_required(True)
@@ -137,14 +137,7 @@ class GitwebApp(app_module.App):
class GitwebWebserverAuth(Webserver):
"""Component to handle Gitweb authentication webserver configuration."""
def is_conf_enabled(self):
"""Check whether Gitweb authentication configuration is enabled."""
return super().is_enabled()
def is_enabled(self):
"""Return if configuration is enabled or public access is enabled."""
repos = get_repo_list()
return have_public_repos(repos) or super().is_enabled()
is_leader = False
def enable(self):
"""Enable apache configuration only if no public repository exists."""