]> git.ardis.lu - git.ardis.lu/commitdiff
Remove the ".git" suffix on the web view
authorArdis Lu <ardisglu@gmail.com>
Sat, 27 Sep 2025 02:48:40 +0000 (19:48 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 27 Sep 2025 02:48:40 +0000 (19:48 -0700)
Symlinks are necessary to retain the original ".git" folder so the clone URLs keep working. The bare non-".git" folder is just for the web view. This behavior matches GitHub and other git forges (i.e., no ".git" in the web URL, but include ".git" in the clone URL).

etc/caddy/Caddyfile
etc/gitweb.conf
srv/git/git-shell-commands/init
srv/git/git-shell-commands/rm
srv/git/projects_list.txt [new file with mode: 0644]

index e659f8628701e09ebbc8289e0fb9edde4b81b178..fe227b814d109309ba79b529514d85a0fbe55dca 100644 (file)
@@ -15,9 +15,9 @@ git.ardis.lu {
     }
   }
 
-  # For /[name] and /[name].git WITHOUT additional paths, redirect to /?p=[name].git for human-friendly browsing
+  # For /[name] and /[name].git WITHOUT additional paths, redirect to /?p=[name] for human-friendly browsing
   @git_bare path_regexp ^(\/)([A-Za-z0-9_.-]+?)(\.git)?$
-  redir @git_bare /?p={re.2}.git
+  redir @git_bare /?p={re.2}
 
   # For /[name].git WITH additional paths, serve git-http-backend to support git operations
   # {method}, {path}, {query} are magic Caddy variables which correspond to the URL
index 734420a1ce0b405381f6bc9068626c487e8ab4f6..7aefdfe46fb5978b4f27a48952b98c673a895836 100644 (file)
@@ -1,5 +1,7 @@
 $projectroot = '/srv/git';
 $git_temp = '/tmp';
+$strict_export = 1; # Repo MUST be listed on $projects_list to be displayed
+$projects_list = $projectroot.'/projects_list.txt';
 
 # https://git-scm.com/docs/gitweb.conf#_links_and_their_targets
 $home_link_str = 'git.ardis.lu';
index a52cc561d690e57316ad4cfe48296bf114096d4f..3ebdec2d88d53fcb87b95c85a0af8d5c343cf392 100644 (file)
@@ -75,4 +75,9 @@ if [ -n "$description" ]; then
   echo "$description" >"$path/description"
 fi
 
+# Set up symlink so /$name --> /$name.git
+# This is needed to drop the ".git" suffix on the web view
+ln -s "$path" "$HOME/$name"
+echo "$name" >>"$HOME/projects_list.txt"
+
 echo "Repository '$name' created"
index a6149896eba692f9fc0a309e422a1a66acc66fed..480b6b8c67f6b71c60d1fd26ff5ae70860001111 100644 (file)
@@ -21,6 +21,8 @@ fi
 # git maintenance unregister --force
 # cd "$HOME"
 
+sed -i "/^$name\$/d" "$HOME/projects_list.txt"
+rm "$HOME/$name"
 rm -r "$path"
 
 echo "Repository '$name' deleted"
diff --git a/srv/git/projects_list.txt b/srv/git/projects_list.txt
new file mode 100644 (file)
index 0000000..e69de29
This page took 0.037382 seconds and 4 git commands to generate.