help command learns to deal with LOCAL_CODE

This commit is contained in:
Sitaram Chamarty 2012-06-19 21:00:53 +05:30
parent 7dcb857347
commit c9d5a13194

View file

@ -20,20 +20,22 @@ usage() if @ARGV;
my $user = $ENV{GL_USER} || ''; my $user = $ENV{GL_USER} || '';
print "hello" . ( $user ? " $user" : "" ) . ", this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n"; print "hello" . ( $user ? " $user" : "" ) . ", this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
_chdir("$ENV{GL_BINDIR}/commands");
print "list of " . ( $user ? "remote" : "gitolite" ) . " commands available:\n\n"; print "list of " . ( $user ? "remote" : "gitolite" ) . " commands available:\n\n";
for my $c (`find . -type f|sort`) { my %list = (list_x( $ENV{GL_BINDIR}), list_x($rc{LOCAL_CODE} || ''));
chomp($c); for (sort keys %list) {
$c =~ s(^./)(); print "\t$list{$_}" if $ENV{D};
next unless -x $c; print "\t$_\n" if not $user or $rc{COMMANDS}{$_};
# if it's from a remote client, show only what he is allowed
next if $user and not $rc{COMMANDS}{$c};
print "\t$c\n";
} }
print "\n"; print "\n";
exit 0; exit 0;
# ------------------------------------------------------------------------------
sub list_x {
my $d = shift;
return unless $d;
_chdir "$d/commands";
return map { $_ => $d } grep { -x $_ } map { chomp; s(^./)(); $_ } `find . -type f|sort`;
}