Browse code

Prepare for serving repositories without the .git suffix

Robert Cranston authored on 17/04/2020 20:07:17
Showing 3 changed files

... ...
@@ -7,8 +7,8 @@ Installs [gitolite][], creates a [dedicated user][] to run it (defaults to
7 7
 (explicit) [user created repos][] with [multiple `OWNERS`][] and `user/USER/*`
8 8
 [personal branches][] for `USERS`, allows users to run [`symbolic-ref`][] (e.g.
9 9
 to change `HEAD`, the default branch), prepares for [integration with a
10
-webserver][] (including acting as a [`git-http-backend`][] replacement), and
11
-allows [custom local code][].
10
+webserver][] (including acting as a [`git-http-backend`][] replacement, and
11
+serving repos without the `.git` suffix), and allows [custom local code][].
12 12
 
13 13
 [`ansible-role-gitolite`]: https://git.rcrnstn.net/rcrnstn/ansible-role-gitolite
14 14
 [Ansible]: https://docs.ansible.com/ansible
15 15
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
... ...
@@ -127,3 +127,9 @@
127 127
       loop:
128 128
         - "{{ gitolite_post_compile_dir }}"
129 129
         - "{{ gitolite_hooks_dir }}"
130
+
131
+    - name: "Override 'update-gitweb-access-list' post-compile trigger"
132
+      copy:
133
+        src: "update-gitweb-access-list"
134
+        dest: "{{ gitolite_post_compile_dir }}/update-gitweb-access-list"
135
+      notify: 'gitolite compile'