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).
}
}
- # 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
$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';
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"
# git maintenance unregister --force
# cd "$HOME"
+sed -i "/^$name\$/d" "$HOME/projects_list.txt"
+rm "$HOME/$name"
rm -r "$path"
echo "Repository '$name' deleted"