summaryrefslogtreecommitdiffstats
path: root/src/triggers/post-compile/update-gitweb-access-list
blob: 4085d593b56b5647442da8dde4460c7ef0a53813 (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
#!/bin/sh

# this is literally the simplest gitweb update possible.  You are free to add
# whatever you want and contribute it back, as long as it is upward
# compatible.

# ----------------------------------------------------------------------
# delete the 'description' file that 'git init' created if this is run from
# the post-create trigger.  However, note that POST_CREATE is also called from
# perms (since POST_CREATE doubles as eqvt of POST_COMPILE to propagate ad hoc
# permissions changes for wild repos) and then you should not delete it.
[ "$1" = "POST_CREATE" ] && [ "$4" != "perms" ] && rm -f $GL_REPO_BASE/$2.git/description 2>/dev/null

plf=`gitolite query-rc GITWEB_PROJECTS_LIST`
[ -z "$plf" ] && plf=$HOME/projects.list
# since mktemp does not honor umask, we just use it to generate a temp
# filename (note: 'mktemp -u' on some systems, this gets close enough)
tmpfile=`mktemp $plf.tmp_XXXXXXXX`
rm -f $tmpfile;

if [ "$1" = "POST_CREATE" ] && [ -n "$2" ]
then
    # just one to be done
    repo="$2"
    grep -v "^$repo.git$" $plf > $tmpfile
    if gitolite access -q $repo gitweb R any || gitolite git-config -q -r $repo gitweb\\.
    then
        echo "$repo.git" >> $tmpfile
    fi
else
    # all of them
    (
        gitolite list-phy-repos | gitolite access % gitweb R any | grep -v DENIED
        gitolite list-phy-repos | gitolite git-config -r % gitweb\\.
    ) |
        cut -f1 | sort -u | sed -e 's/$/.git/' > $tmpfile
fi

[ -f $plf ] && perl -e "chmod ( ( (stat('$plf'))[2] & 07777 ), '$tmpfile')"
mv $tmpfile $plf