Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DEFAULT_ROLE_PERMS replaced by per repo 'default.roles' option

  • Loading branch information...
commit 0419d9958809a840a813df05547b67618b4150c5 1 parent 09e3a3c
@sitaramc authored
View
6 src/commands/fork
@@ -44,12 +44,6 @@ echo "$from forked to $to" >&2
cd $GL_REPO_BASE/$to.git
echo $GL_USER > gl-creator
-touch gl-perms
-if gitolite query-rc -q DEFAULT_ROLE_PERMS
-then
- gitolite query-rc DEFAULT_ROLE_PERMS > gl-perms
-fi
-
ln -sf `gitolite query-rc GL_ADMIN_BASE`/hooks/common/* hooks
# record where you came from
View
1  src/lib/Gitolite/Conf/Store.pm
@@ -191,7 +191,6 @@ sub new_wild_repo {
trigger( 'PRE_CREATE', $repo, $user, $aa );
new_repo($repo);
_print( "$repo.git/gl-creator", $user );
- _print( "$repo.git/gl-perms", ( $rc{DEFAULT_ROLE_PERMS} ? "$rc{DEFAULT_ROLE_PERMS}\n" : "" ) );
trigger( 'POST_CREATE', $repo, $user, $aa );
_chdir( $rc{GL_ADMIN_BASE} );
View
7 src/lib/Gitolite/Rc.pm
@@ -405,6 +405,8 @@ BEGIN { $non_core = "
ssh-authkeys POST_COMPILE post-compile/ssh-authkeys
Shell POST_COMPILE post-compile/ssh-authkeys-shell-users
+ set-default-roles POST_CREATE .
+
git-config POST_COMPILE post-compile/update-git-configs
git-config POST_CREATE post-compile/update-git-configs
@@ -458,8 +460,6 @@ __DATA__
READERS => 1,
WRITERS => 1,
},
- # uncomment (and change) this if you wish
- # DEFAULT_ROLE_PERMS => 'READERS @all',
# ------------------------------------------------------------------
@@ -535,6 +535,9 @@ __DATA__
# give some users direct shell access
# 'Shell',
+ # set default roles from lines like 'option default.roles-1 = ...', etc.
+ # 'set-default-roles',
+
# system admin stuff
# enable mirroring (don't forget to set the HOSTNAME too!)
View
14 src/triggers/set-default-roles
@@ -0,0 +1,14 @@
+#!/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;
+
+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
View
24 t/fork.t
@@ -5,11 +5,12 @@ use warnings;
# this is hardcoded; change it if needed
use lib "src/lib";
use Gitolite::Test;
+my $h = $ENV{HOME};
# fork command
# ----------------------------------------------------------------------
-try "plan 30";
+try "plan 38";
my $rb = `gitolite query-rc -n GL_REPO_BASE`;
@@ -34,7 +35,23 @@ try "
# allow fork as a valid command
$ENV{G3T_RC} = "$ENV{HOME}/g3trc";
-put "$ENV{G3T_RC}", "\$rc{COMMANDS}{fork} = 1;\n\$rc{DEFAULT_ROLE_PERMS} = 'READERS \@all';\n";
+put "$ENV{G3T_RC}", "\$rc{COMMANDS}{fork} = 1;\n";
+
+# enable set-default-roles feature, add options, push
+try "
+ cat $h/.gitolite.rc
+ perl s/# 'set-default-roles'/'set-default-roles'/
+ put $h/.gitolite.rc
+";
+try "cd gitolite-admin";
+confadd '
+ repo foo/CREATOR/..*
+ C = u1 u2
+ RW+ = CREATOR
+ option default.roles-1 = READERS @all
+';
+try "ADMIN_PUSH set1; !/FATAL/" or die text();
+try "cd ..";
try "
# now the fork succeeds
@@ -61,8 +78,7 @@ try "
my $t;
try "cd $rb; find . -name gl-perms"; $t = md5sum(sort (lines())); cmp $t,
-'d41d8cd98f00b204e9800998ecf8427e ./foo/u1/u1a.git/gl-perms
-59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1a2.git/gl-perms
+'59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1a2.git/gl-perms
59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1e.git/gl-perms
';
Please sign in to comment.
Something went wrong with that request. Please try again.