summaryrefslogtreecommitdiffstats
path: root/src/triggers/set-default-roles
blob: dbbcc92f12fda2afc1f39836885e72a3953d01c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

# POST_CREATE trigger to set up default set of perms for a new wild repo

# ----------------------------------------------------------------------
# skip if arg-1 is POST_CREATE and no arg-3 (user name) exists (i.e., it's not
# a wild repo)
[ "$1" = "POST_CREATE" ] && [ -z "$3" ] && exit 0;
[ "$4" = "R" ] || [ "$4" = "W" ] || [ "$4" = "perms-c" ] || [ "$4" = "create" ] || [ "$4" = "fork" ] || exit 0

die() { echo "$@" >&2; exit 1; }

cd $GL_REPO_BASE/$2.git || die "could not cd to $GL_REPO_BASE/$2.git"
gitolite git-config -r $2 gitolite-options.default.roles | sort | cut -f3 |
    perl -pe 's/(\s)CREATOR(\s|$)/$1$ENV{GL_USER}$2/' > gl-perms

# cache control, if rc says caching is on
gitolite query-rc -q CACHE && perl -I$GL_LIBDIR -MGitolite::Cache -e "cache_control('flush', '$2')";

exit 0