rewrite create command
[gitolite.git] / src / triggers / set-default-roles
blobdbbcc92f12fda2afc1f39836885e72a3953d01c3
1 #!/bin/sh
3 # POST_CREATE trigger to set up default set of perms for a new wild repo
5 # ----------------------------------------------------------------------
6 # skip if arg-1 is POST_CREATE and no arg-3 (user name) exists (i.e., it's not
7 # a wild repo)
8 [ "$1" = "POST_CREATE" ] && [ -z "$3" ] && exit 0;
9 [ "$4" = "R" ] || [ "$4" = "W" ] || [ "$4" = "perms-c" ] || [ "$4" = "create" ] || [ "$4" = "fork" ] || exit 0
11 die() { echo "$@" >&2; exit 1; }
13 cd $GL_REPO_BASE/$2.git || die "could not cd to $GL_REPO_BASE/$2.git"
14 gitolite git-config -r $2 gitolite-options.default.roles | sort | cut -f3 |
15 perl -pe 's/(\s)CREATOR(\s|$)/$1$ENV{GL_USER}$2/' > gl-perms
17 # cache control, if rc says caching is on
18 gitolite query-rc -q CACHE && perl -I$GL_LIBDIR -MGitolite::Cache -e "cache_control('flush', '$2')";
20 exit 0