Browse code

Prepare for serving repositories without the .git suffix

Robert Cranston authored on 17/04/2020 20:07:17
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,34 @@
1
+#!/bin/sh
2
+set -euC
3
+
4
+# This does the same thing (in fact uses) the built in version except that it
5
+# does not include the `.git` suffixes.
6
+
7
+# Run the built-in version.
8
+"$GL_BINDIR/triggers/post-compile/update-gitweb-access-list"
9
+
10
+# Clear previous links.
11
+find "$GL_REPO_BASE" -name '*.git' -prune -o -type l -exec rm {} +
12
+# Create new links.
13
+gitolite list-phy-repos \
14
+| while IFS= read -r repo
15
+do
16
+    mkdir -p "$(dirname "$GL_REPO_BASE/$repo")"
17
+    ln -s \
18
+        "$GL_REPO_BASE/$repo.git" \
19
+        "$GL_REPO_BASE/$repo"
20
+done
21
+
22
+# Determine projects list file.
23
+projects_list="$(
24
+    gitolite query-rc GITWEB_PROJECTS_LIST ||
25
+    echo "$HOME/projects.list"
26
+)"
27
+# Process and write.
28
+if [ -r "$projects_list" ]
29
+then
30
+    tmp="$(mktemp)"
31
+    < "$projects_list" sed 's/\.git$//' >| "$tmp"
32
+    < "$tmp" cat >| "$projects_list"
33
+    rm "$tmp"
34
+fi