autoviv new repos by user only on "C" access

we've removed the facility of auto-viving "W" access repos when they are
not wildcards.  A wildcard pattern like foo/CREATER was
indistinguishable from a non-wildcard repo, and resolving it was
becoming kludgier and kludgier.  (See the revert in the commit before
this one for details).

As a side effect of not being able to distinguish wildcard repos from
real repos easily, the expand command now works for a normal repo too
(because we have to make it work for "foo/CREATER")
This commit is contained in:
Sitaram Chamarty 2009-12-21 17:49:21 +05:30 committed by Sitaram Chamarty
parent 981d693dec
commit 6fb2296e2c
2 changed files with 8 additions and 12 deletions

View file

@ -179,6 +179,8 @@ sub parse_acl
return unless $repo; return unless $repo;
return $ENV{GL_REPOPATT} = "" if $repos{$repo}; return $ENV{GL_REPOPATT} = "" if $repos{$repo};
# didn't find $repo in %repos, so it must be a wildcard-match case
my @matched = grep { $repo =~ /^$_$/ } sort keys %repos; my @matched = grep { $repo =~ /^$_$/ } sort keys %repos;
die "$repo has no matches\n" unless @matched; die "$repo has no matches\n" unless @matched;
die "$repo has multiple matches\n@matched\n" if @matched > 1; die "$repo has multiple matches\n@matched\n" if @matched > 1;

View file

@ -99,7 +99,7 @@ if ($cmd =~ $CUSTOM_COMMANDS) {
# with an actual reponame, you can "getperms" or "setperms" # with an actual reponame, you can "getperms" or "setperms"
get_set_perms($repo_base_abs, $repo, $verb, $user); get_set_perms($repo_base_abs, $repo, $verb, $user);
} }
elsif ($repo !~ $REPONAME_PATT and $verb eq 'expand') { elsif ($verb eq 'expand') {
# with a wildcard, you can "expand" it to see what repos actually match # with a wildcard, you can "expand" it to see what repos actually match
expand_wild($GL_CONF_COMPILED, $repo_base_abs, $repo, $user); expand_wild($GL_CONF_COMPILED, $repo_base_abs, $repo, $user);
} else { } else {
@ -143,20 +143,14 @@ die "$repo has two consecutive periods; I don't like that\n" if $repo =~ /\.\./;
if ( -d "$repo_base_abs/$repo.git" ) { if ( -d "$repo_base_abs/$repo.git" ) {
# existing repo # existing repo
my ($creater, $user_R, $user_W) = &repo_rights($repo_base_abs, $repo, $user); my ($creater, $user_R, $user_W) = &repo_rights($repo_base_abs, $repo, $user);
my $patt = &parse_acl($GL_CONF_COMPILED, $repo, $creater, $user_R, $user_W); &parse_acl($GL_CONF_COMPILED, $repo, $creater, $user_R, $user_W);
} else { } else {
my $patt = &parse_acl($GL_CONF_COMPILED, $repo, $user, $user, $user); &parse_acl($GL_CONF_COMPILED, $repo, $user, $user, $user);
# parse_acl returns "" if the repo was non-wildcard, or the pattern
# that matched if it was a wildcard
# auto-vivify new repo; 2 situations allow autoviv -- normal repos # auto-vivify new repo if you have C access
# with W access (the old mode), and wildcard repos with C access if ( $repos{$repo}{C}{$user} || $repos{$repo}{C}{'@all'} ) {
my $W_ok = $repos{$repo}{W}{$user} || $repos{$repo}{W}{'@all'};
my $C_ok = $repos{$repo}{C}{$user} || $repos{$repo}{C}{'@all'};
if ($W_ok and not $patt or $C_ok and $patt) {
wrap_chdir("$repo_base_abs"); wrap_chdir("$repo_base_abs");
# for wildcard repos, we also want to set the "creater" new_repo($repo, "$GL_ADMINDIR/src/hooks", $user);
new_repo($repo, "$GL_ADMINDIR/src/hooks", ( $patt ? $user : ""));
wrap_chdir($ENV{HOME}); wrap_chdir($ENV{HOME});
} }
} }