summaryrefslogtreecommitdiff
path: root/src/triggers/post-compile/update-git-daemon-access-list
blob: 446b0da900d2347e33aa6c475ac76184047e24c5 (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
40
41
#!/usr/bin/perl

# update git-daemon-export-ok files in each repo
# ----------------------------------------------------------------------

use lib $ENV{GL_LIBDIR};
use Gitolite::Rc;
use Gitolite::Easy;
use Gitolite::Common;

use strict;
use warnings;

# ----------------------------------------------------------------------
# skip if arg-0 is POST_CREATE and no arg-2 (user name) exists; this means
# it's been triggered by a *normal* (not "wild") repo creation, which in turn
# means a POST_COMPILE should be following so there's no need to waste time
# running this once for each new repo
exit 0 if @ARGV and $ARGV[0] eq 'POST_CREATE' and not $ARGV[2];

my $EO = "git-daemon-export-ok";
my $RB = $rc{GL_REPO_BASE};

for my $d (`gitolite list-phy-repos | gitolite access % daemon R any`) {
    my @F = split "\t", $d;
    if ($F[2] =~ /DENIED/) {
        unlink "$RB/$F[0].git/$EO";
    } else {
        textfile( file => $EO, repo => $F[0], text => "" );
    }
}

# As a quick recap, the gitolite output looks somewhat like this:

#   bar^Idaemon^IR any bar daemon DENIED by fallthru$
#   foo^Idaemon^Irefs/.*$
#   fubar^Idaemon^Irefs/.*$
#   gitolite-admin^Idaemon^IR any gitolite-admin daemon DENIED by fallthru$
#   testing^Idaemon^Irefs/.*$

# where I've typed "^I" to denote a tab.