minor fixups to the "gitweb/daemon from setperms" code...
- fork was not printing a newline after the permissions - "add_del_line" to properly handle that damn projects.list file!
This commit is contained in:
parent
870983086c
commit
3a8f32ac9b
|
@ -231,7 +231,7 @@ $GL_WILDREPOS = 0;
|
|||
# as desired after repository creation; it is only a default. Note that @all can be
|
||||
# used here but is special; no other groups can be used in user-level permissions.
|
||||
|
||||
# $GL_WILDREPOS_DEFPERMS = 'R = @all';
|
||||
# $GL_WILDREPOS_DEFPERMS = 'R @all';
|
||||
|
||||
# --------------------------------------
|
||||
# HOOK CHAINING
|
||||
|
|
|
@ -19,7 +19,7 @@ git clone --bare -l $GL_REPO_BASE_ABS/$from.git $GL_REPO_BASE_ABS/$to.git
|
|||
cd $GL_REPO_BASE_ABS/$to.git
|
||||
echo $GL_USER > gl-creater
|
||||
git config gitweb.owner "$GL_USER"
|
||||
( cd $HOME;perl -e 'do ".gitolite.rc"; print $GL_WILDREPOS_DEFPERMS' ) |
|
||||
( cd $HOME;perl -le 'do ".gitolite.rc"; print $GL_WILDREPOS_DEFPERMS' ) |
|
||||
SSH_ORIGINAL_COMMAND="setperms $to" $GL_BINDIR/gl-auth-command $GL_USER
|
||||
cp -R $GL_REPO_BASE_ABS/$from.git/hooks/* $GL_REPO_BASE_ABS/$to.git/hooks
|
||||
|
||||
|
|
|
@ -66,6 +66,26 @@ sub wrap_print {
|
|||
close($fh);
|
||||
}
|
||||
|
||||
sub add_del_line {
|
||||
my ($line, $file, $flag) = @_;
|
||||
my $contents;
|
||||
|
||||
local $/ = undef;
|
||||
my $fh = wrap_open("<", $file);
|
||||
$contents = <$fh>;
|
||||
$contents =~ s/\s+$/\n/;
|
||||
|
||||
if ($flag and $contents !~ /^\Q$line\E$/m) {
|
||||
# add line if it doesn't exist
|
||||
$contents .= "$line\n";
|
||||
wrap_print($file, $contents);
|
||||
}
|
||||
if (not $flag and $contents =~ /^\Q$line\E$/m) {
|
||||
$contents =~ s/^\Q$line\E(\n|$)//m;
|
||||
wrap_print($file, $contents);
|
||||
}
|
||||
}
|
||||
|
||||
sub dbg {
|
||||
for my $i (@_) {
|
||||
print STDERR "DBG: $i\n";
|
||||
|
@ -279,7 +299,8 @@ sub get_set_perms
|
|||
|
||||
# gitweb and daemon
|
||||
setup_daemon_access($repo);
|
||||
system("echo $repo.git >> $PROJECTS_LIST") if &setup_gitweb_access($repo, '', '');
|
||||
# add or delete line (arg1) from file (arg2) depending on arg3
|
||||
&add_del_line ("$repo.git", $PROJECTS_LIST, &setup_gitweb_access($repo, '', ''));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ if ($perm =~ /C/) {
|
|||
wrap_print("gl-perms", "$GL_WILDREPOS_DEFPERMS\n") if $GL_WILDREPOS_DEFPERMS;
|
||||
&setup_repo_configs($repo, \%repo_config);
|
||||
&setup_daemon_access($repo);
|
||||
system("echo $repo.git >> $PROJECTS_LIST") if &setup_gitweb_access($repo, '', '');
|
||||
&add_del_line ("$repo.git", $PROJECTS_LIST, &setup_gitweb_access($repo, '', ''));
|
||||
wrap_chdir($ENV{HOME});
|
||||
}
|
||||
|
||||
|
|
|
@ -109,18 +109,9 @@ do
|
|||
runlocal git ls-remote u1:bar/u1/try6
|
||||
runremote ls -al repositories/bar/u1/try6.git/git-daemon-export-ok
|
||||
expect "ls: cannot access repositories/bar/u1/try6.git/git-daemon-export-ok: No such file or directory"
|
||||
# projects.list currently does not get cleared until a compile, so you
|
||||
# will still see the entry for .../try6
|
||||
runremote ls -al projects.list
|
||||
expect "gitolite-test gitolite-test 76 .* projects.list"
|
||||
runremote cat projects.list
|
||||
expect "bar/u1/try6.git"
|
||||
|
||||
echo | ugc
|
||||
runremote ls -al projects.list
|
||||
expect "gitolite-test gitolite-test 60 .* projects.list"
|
||||
runremote cat projects.list
|
||||
# but *now* it should be gone
|
||||
notexpect "bar/u1/try6.git"
|
||||
|
||||
name "INTERNAL"
|
||||
|
|
Loading…
Reference in a new issue