auto-create repo on 'C' perm done
This commit is contained in:
parent
a014d2ffd5
commit
89a1857d56
|
@ -7,6 +7,7 @@ package Gitolite::Conf::Load;
|
||||||
load
|
load
|
||||||
access
|
access
|
||||||
git_config
|
git_config
|
||||||
|
repo_missing
|
||||||
vrefs
|
vrefs
|
||||||
lister_dispatch
|
lister_dispatch
|
||||||
);
|
);
|
||||||
|
@ -111,7 +112,7 @@ sub git_config {
|
||||||
# if it has an entry in %configs
|
# if it has an entry in %configs
|
||||||
grep { $configs{$_} }
|
grep { $configs{$_} }
|
||||||
# for each "repo" that represents us
|
# for each "repo" that represents us
|
||||||
memberships('repo', $repo);
|
memberships( 'repo', $repo );
|
||||||
|
|
||||||
# %configs looks like this (for each 'foo' that is in memberships())
|
# %configs looks like this (for each 'foo' that is in memberships())
|
||||||
# 'foo' => [ [ 6, 'foo.bar', 'repo' ], [ 7, 'foodbar', 'repoD' ], [ 8, 'foo.czar', 'jule' ] ],
|
# 'foo' => [ [ 6, 'foo.bar', 'repo' ], [ 7, 'foodbar', 'repoD' ], [ 8, 'foo.czar', 'jule' ] ],
|
||||||
|
@ -128,6 +129,11 @@ sub git_config {
|
||||||
return \%ret;
|
return \%ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub repo_missing {
|
||||||
|
my $repo = shift;
|
||||||
|
return not -d "$rc{GL_REPO_BASE}/$repo.git";
|
||||||
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
sub load_common {
|
sub load_common {
|
||||||
|
@ -158,6 +164,10 @@ sub load_1 {
|
||||||
return if $repo =~ /^\@/;
|
return if $repo =~ /^\@/;
|
||||||
trace( 3, $repo );
|
trace( 3, $repo );
|
||||||
|
|
||||||
|
if ( repo_missing($repo) ) {
|
||||||
|
trace( 3, "repo '$repo' missing" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
_chdir("$rc{GL_REPO_BASE}/$repo.git");
|
_chdir("$rc{GL_REPO_BASE}/$repo.git");
|
||||||
|
|
||||||
if ( $repo eq $last_repo ) {
|
if ( $repo eq $last_repo ) {
|
||||||
|
@ -193,8 +203,8 @@ sub load_1 {
|
||||||
|
|
||||||
my @rules = ();
|
my @rules = ();
|
||||||
|
|
||||||
my @repos = memberships('repo', $repo);
|
my @repos = memberships( 'repo', $repo );
|
||||||
my @users = memberships('user', $user);
|
my @users = memberships( 'user', $user );
|
||||||
trace( 3, "memberships: " . scalar(@repos) . " repos and " . scalar(@users) . " users found" );
|
trace( 3, "memberships: " . scalar(@repos) . " repos and " . scalar(@users) . " users found" );
|
||||||
|
|
||||||
for my $r (@repos) {
|
for my $r (@repos) {
|
||||||
|
@ -230,30 +240,29 @@ sub memberships {
|
||||||
|
|
||||||
my @ret = ( $item, '@all' );
|
my @ret = ( $item, '@all' );
|
||||||
|
|
||||||
if ($type eq 'repo') {
|
if ( $type eq 'repo' ) {
|
||||||
my $f = "$rc{GL_REPO_BASE}/$item.git/gl-creator";
|
my $f = "$rc{GL_REPO_BASE}/$item.git/gl-creator";
|
||||||
if (-f $f) {
|
if ( -f $f ) {
|
||||||
my $creator;
|
my $creator;
|
||||||
chomp($creator = slurp($f));
|
chomp( $creator = slurp($f) );
|
||||||
($item2 = $item) =~ s(/$creator/)(/CREATOR/);
|
( $item2 = $item ) =~ s(/$creator/)(/CREATOR/);
|
||||||
$item2 = '' if $item2 eq $item; # no change
|
$item2 = '' if $item2 eq $item; # no change
|
||||||
}
|
}
|
||||||
for my $i (keys %repos) {
|
for my $i ( keys %repos ) {
|
||||||
if ($item eq $i or $item =~ /^$i$/ or $item2 and ( $item2 eq $i or $item2 =~ /^$i$/ )) {
|
if ( $item eq $i or $item =~ /^$i$/ or $item2 and ( $item2 eq $i or $item2 =~ /^$i$/ ) ) {
|
||||||
push @ret, $i;
|
push @ret, $i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $i (keys %groups) {
|
for my $i ( keys %groups ) {
|
||||||
if ($item eq $i or $item =~ /^$i$/ or $item2 and ( $item2 eq $i or $item2 =~ /^$i$/ )) {
|
if ( $item eq $i or $item =~ /^$i$/ or $item2 and ( $item2 eq $i or $item2 =~ /^$i$/ ) ) {
|
||||||
push @ret, @{ $groups{$i} };
|
push @ret, @{ $groups{$i} };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ret = @{ sort_u(\@ret) };
|
@ret = @{ sort_u( \@ret ) };
|
||||||
dbg(\@ret);
|
|
||||||
return @ret;
|
return @ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +358,7 @@ sub list_memberships {
|
||||||
my $name = shift;
|
my $name = shift;
|
||||||
|
|
||||||
load_common();
|
load_common();
|
||||||
my @m = memberships('', $name);
|
my @m = memberships( '', $name );
|
||||||
return ( sort_u( \@m ) );
|
return ( sort_u( \@m ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ package Gitolite::Conf::Store;
|
||||||
expand_list
|
expand_list
|
||||||
new_repos
|
new_repos
|
||||||
new_repo
|
new_repo
|
||||||
|
new_wild_repo
|
||||||
hook_repos
|
hook_repos
|
||||||
store
|
store
|
||||||
parse_done
|
parse_done
|
||||||
|
@ -126,7 +127,7 @@ sub add_rule {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_config {
|
sub add_config {
|
||||||
my($n, $key, $value) = @_;
|
my ( $n, $key, $value ) = @_;
|
||||||
|
|
||||||
$nextseq++;
|
$nextseq++;
|
||||||
for my $repo (@repolist) {
|
for my $repo (@repolist) {
|
||||||
|
@ -194,6 +195,17 @@ sub new_repo {
|
||||||
# XXX ignoring gl-post-init for now
|
# XXX ignoring gl-post-init for now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub new_wild_repo {
|
||||||
|
my ( $repo, $user ) = @_;
|
||||||
|
_chdir( $rc{GL_REPO_BASE} );
|
||||||
|
new_repo($repo);
|
||||||
|
_print( "$repo.git/gl-creator", $user );
|
||||||
|
# XXX _print("$repo.git/gl-perms", "$rc{WILDREPOS_DEFAULT_PERMS}\n") if $rc{WILDREPOS_DEFAULT_PERMS};
|
||||||
|
# XXX git config, daemon, web...
|
||||||
|
# XXX pre-create, post-create
|
||||||
|
_chdir( $rc{GL_ADMIN_BASE} );
|
||||||
|
}
|
||||||
|
|
||||||
sub hook_repos {
|
sub hook_repos {
|
||||||
trace(3);
|
trace(3);
|
||||||
# all repos, all hooks
|
# all repos, all hooks
|
||||||
|
|
|
@ -61,6 +61,13 @@ sub main {
|
||||||
$ENV{GL_REPO} = $repo;
|
$ENV{GL_REPO} = $repo;
|
||||||
my $aa = ( $verb =~ 'upload' ? 'R' : 'W' );
|
my $aa = ( $verb =~ 'upload' ? 'R' : 'W' );
|
||||||
|
|
||||||
|
# auto-create?
|
||||||
|
if ( repo_missing($repo) and access( $repo, $user, '^C', 'any' ) !~ /DENIED/ ) {
|
||||||
|
require Gitolite::Conf::Store;
|
||||||
|
Gitolite::Conf::Store->import;
|
||||||
|
new_wild_repo( $repo, $user );
|
||||||
|
}
|
||||||
|
|
||||||
# a ref of 'any' signifies that this is a pre-git check, where we don't
|
# a ref of 'any' signifies that this is a pre-git check, where we don't
|
||||||
# yet know the ref that will be eventually pushed (and even that won't
|
# yet know the ref that will be eventually pushed (and even that won't
|
||||||
# apply if it's a read operation). See the matching code in access() for
|
# apply if it's a read operation). See the matching code in access() for
|
||||||
|
|
Loading…
Reference in a new issue