summaryrefslogtreecommitdiffstats
path: root/roles/people/files/cgit.conf
blob: 2964654f7ba6d82b22a194980a3b8b0202dc1160 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Alias /cgit-data /usr/share/cgit

# This code is copied from the regular /git cloning code. Since our cgit
# https clones don't seem to support push, we should be able to get away with
# copying a very similar config as for /git.

# Begin http git clone
#  First, deny write access
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} /git-receive-pack$
RewriteRule ^/cgit/ - [E=AUTHREQUIRED:yes]
<Location /cgit>
  <RequireAll>
    Require not env AUTHREQUIRED
    Require all granted
  </RequireAll>
  Options -Indexes +ExecCGI
</Location>

#  Next up, determine which user owns this repo
SetEnvIf Request_URI ^/cgit/([a-zA-Z0-9]*)/.* GIT_PROJECT_ROOT=/home/fedora/$1/public_git
Header set X-GitProject "%{GIT_PROJECT_ROOT}e"

#  Let's serve objects and packs directly from apache, very performant!
AliasMatch ^/cgit/([a-zA-Z0-9]*)/public_git/([a-zA-Z0-9]*)\.git(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /home/fedora/$1/public_git/$2.git/$3
AliasMatch ^/cgit/([a-zA-Z0-9]*)/public_git/([a-zA-Z0-9]*)\.git(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /home/fedora/$1/public_git/$2.git/$3

#  And now for the magic, let's run the git cgi script
ScriptAliasMatch \
	"(?x)^/cgit/([a-zA-Z0-9]*)/public_git/(.*/(HEAD | \
			info/refs | \
			objects/(info/[^/]+ | \
				 [0-9a-f]{2}/[0-9a-f]{38} | \
				 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
			git-(upload|receive)-pack))$" \
        /usr/libexec/git-core/git-http-backend/$2
# End http git clone

ScriptAlias /cgit /var/www/cgi-bin/cgit