(perltidy)
This commit is contained in:
parent
afcd974afa
commit
8714b77eae
|
@ -77,8 +77,8 @@ sub _die {
|
||||||
sub usage {
|
sub usage {
|
||||||
_warn(shift) if @_;
|
_warn(shift) if @_;
|
||||||
my ( $script, $function ) = ( caller(1) )[ 1, 3 ];
|
my ( $script, $function ) = ( caller(1) )[ 1, 3 ];
|
||||||
if (not $script) {
|
if ( not $script ) {
|
||||||
$script = ( caller ) [1];
|
$script = (caller)[1];
|
||||||
$function = 'usage';
|
$function = 'usage';
|
||||||
}
|
}
|
||||||
dbg( "u s a g e", $script, $function );
|
dbg( "u s a g e", $script, $function );
|
||||||
|
@ -115,7 +115,7 @@ sub _system {
|
||||||
die "child died with signal " . ( $? & 127 ) . "\n" if $ENV{D};
|
die "child died with signal " . ( $? & 127 ) . "\n" if $ENV{D};
|
||||||
} else {
|
} else {
|
||||||
die "child exited with value " . ( $? >> 8 ) . "\n" if $ENV{D};
|
die "child exited with value " . ( $? >> 8 ) . "\n" if $ENV{D};
|
||||||
exit ( $? >> 8 );
|
exit( $? >> 8 );
|
||||||
}
|
}
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ sub incsub {
|
||||||
_die "subconf $subconf attempting to run 'subconf'\n" if $is_subconf and $subconf ne 'master';
|
_die "subconf $subconf attempting to run 'subconf'\n" if $is_subconf and $subconf ne 'master';
|
||||||
|
|
||||||
_die "invalid include/subconf file/glob '$include_glob'"
|
_die "invalid include/subconf file/glob '$include_glob'"
|
||||||
unless $include_glob =~ /^"(.+)"$/
|
unless $include_glob =~ /^"(.+)"$/
|
||||||
or $include_glob =~ /^'(.+)'$/;
|
or $include_glob =~ /^'(.+)'$/;
|
||||||
$include_glob = $1;
|
$include_glob = $1;
|
||||||
|
|
||||||
# XXX move this to Macros... substitute HOSTNAME word if GL_HOSTNAME defined, otherwise leave as is
|
# XXX move this to Macros... substitute HOSTNAME word if GL_HOSTNAME defined, otherwise leave as is
|
||||||
|
|
|
@ -67,8 +67,8 @@ sub access {
|
||||||
my @rules = rules( $repo, $user );
|
my @rules = rules( $repo, $user );
|
||||||
trace( 3, scalar(@rules) . " rules found" );
|
trace( 3, scalar(@rules) . " rules found" );
|
||||||
for my $r (@rules) {
|
for my $r (@rules) {
|
||||||
my $perm = $r->[1];
|
my $perm = $r->[1];
|
||||||
my $refex = $r->[2]; $refex =~ s(/USER/)(/$user/);
|
my $refex = $r->[2]; $refex =~ s(/USER/)(/$user/);
|
||||||
trace( 4, "perm=$perm, refex=$refex" );
|
trace( 4, "perm=$perm, refex=$refex" );
|
||||||
|
|
||||||
# skip 'deny' rules if the ref is not (yet) known
|
# skip 'deny' rules if the ref is not (yet) known
|
||||||
|
|
|
@ -116,7 +116,7 @@ sub parse_users {
|
||||||
|
|
||||||
sub add_rule {
|
sub add_rule {
|
||||||
my ( $perm, $ref, $user ) = @_;
|
my ( $perm, $ref, $user ) = @_;
|
||||||
_die "bad ref '$ref'" unless $ref =~ $REPOPATT_PATT;
|
_die "bad ref '$ref'" unless $ref =~ $REPOPATT_PATT;
|
||||||
_die "bad user '$user'" unless $user =~ $USERNAME_PATT;
|
_die "bad user '$user'" unless $user =~ $USERNAME_PATT;
|
||||||
|
|
||||||
$ruleseq++;
|
$ruleseq++;
|
||||||
|
|
|
@ -53,9 +53,9 @@ _die "$rc seems to be for older gitolite" if defined($GL_ADMINDIR);
|
||||||
# let values specified in rc file override our internal ones
|
# let values specified in rc file override our internal ones
|
||||||
@rc{ keys %RC } = values %RC;
|
@rc{ keys %RC } = values %RC;
|
||||||
|
|
||||||
# testing sometimes requires all of it to be overridden silently; use an
|
# testing sometimes requires all of it to be overridden silently; use an
|
||||||
# env var that is highly unlikely to appear in real life :)
|
# env var that is highly unlikely to appear in real life :)
|
||||||
do $ENV{G3T_RC} if exists $ENV{G3T_RC} and -r $ENV{G3T_RC};
|
do $ENV{G3T_RC} if exists $ENV{G3T_RC} and -r $ENV{G3T_RC};
|
||||||
|
|
||||||
# fix PATH (TODO: do it only if 'gitolite' isn't in PATH)
|
# fix PATH (TODO: do it only if 'gitolite' isn't in PATH)
|
||||||
$ENV{PATH} = "$ENV{GL_BINDIR}:$ENV{PATH}";
|
$ENV{PATH} = "$ENV{GL_BINDIR}:$ENV{PATH}";
|
||||||
|
|
|
@ -50,9 +50,9 @@ sub args {
|
||||||
my $argv = join( " ", @ARGV );
|
my $argv = join( " ", @ARGV );
|
||||||
|
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'admin|a=s' => \$admin,
|
'admin|a=s' => \$admin,
|
||||||
'pubkey|pk=s' => \$pubkey,
|
'pubkey|pk=s' => \$pubkey,
|
||||||
'help|h' => \$help,
|
'help|h' => \$help,
|
||||||
) or usage();
|
) or usage();
|
||||||
|
|
||||||
usage() if $help or ($pubkey and $admin);
|
usage() if $help or ($pubkey and $admin);
|
||||||
|
@ -79,9 +79,9 @@ sub setup_glrc {
|
||||||
|
|
||||||
sub setup_gladmin {
|
sub setup_gladmin {
|
||||||
my ( $admin, $pubkey, $argv ) = @_;
|
my ( $admin, $pubkey, $argv ) = @_;
|
||||||
trace( 1, $admin || '<no admin name given>');
|
trace( 1, $admin || '<no admin name given>' );
|
||||||
_die "no existing conf file found, '-a' required"
|
_die "no existing conf file found, '-a' required"
|
||||||
if not $admin and not -f "$rc{GL_ADMIN_BASE}/conf/gitolite.conf";
|
if not $admin and not -f "$rc{GL_ADMIN_BASE}/conf/gitolite.conf";
|
||||||
|
|
||||||
# reminder: 'admin files' are in ~/.gitolite, 'admin repo' is
|
# reminder: 'admin files' are in ~/.gitolite, 'admin repo' is
|
||||||
# $rc{GL_REPO_BASE}/gitolite-admin.git
|
# $rc{GL_REPO_BASE}/gitolite-admin.git
|
||||||
|
@ -96,7 +96,7 @@ sub setup_gladmin {
|
||||||
_chdir( $rc{GL_ADMIN_BASE} );
|
_chdir( $rc{GL_ADMIN_BASE} );
|
||||||
|
|
||||||
tsh_try("cd \$GL_BINDIR; git describe --tags --long --dirty=-dt 2>/dev/null")
|
tsh_try("cd \$GL_BINDIR; git describe --tags --long --dirty=-dt 2>/dev/null")
|
||||||
and _print("VERSION", tsh_text());
|
and _print( "VERSION", tsh_text() );
|
||||||
|
|
||||||
_mkdir("conf");
|
_mkdir("conf");
|
||||||
my $conf;
|
my $conf;
|
||||||
|
|
|
@ -25,7 +25,7 @@ BEGIN {
|
||||||
*{'try'} = \&Tsh::try;
|
*{'try'} = \&Tsh::try;
|
||||||
*{'put'} = \&Tsh::put;
|
*{'put'} = \&Tsh::put;
|
||||||
*{'text'} = \&Tsh::text;
|
*{'text'} = \&Tsh::text;
|
||||||
*{'cmp'} = \&Tsh::cmp;
|
*{'cmp'} = \&Tsh::cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
@ -72,12 +72,12 @@ sub dump {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _confargs {
|
sub _confargs {
|
||||||
return @_ if ($_[1]);
|
return @_ if ( $_[1] );
|
||||||
return 'gitolite.conf', $_[0];
|
return 'gitolite.conf', $_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub confreset {
|
sub confreset {
|
||||||
system("rm", "-rf", "conf");
|
system( "rm", "-rf", "conf" );
|
||||||
mkdir("conf");
|
mkdir("conf");
|
||||||
system("mv ~/repositories/gitolite-admin.git ~/repositories/.ga");
|
system("mv ~/repositories/gitolite-admin.git ~/repositories/.ga");
|
||||||
system("mv ~/repositories/testing.git ~/repositories/.te");
|
system("mv ~/repositories/testing.git ~/repositories/.te");
|
||||||
|
@ -93,7 +93,7 @@ sub confreset {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub confadd {
|
sub confadd {
|
||||||
my ($file, $string) = _confargs(@_);
|
my ( $file, $string ) = _confargs(@_);
|
||||||
put "|cat >> conf/$file", $string;
|
put "|cat >> conf/$file", $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,13 +473,13 @@ sub fail {
|
||||||
sub cmp {
|
sub cmp {
|
||||||
# compare input string with text()
|
# compare input string with text()
|
||||||
my $text = text();
|
my $text = text();
|
||||||
my $in = shift;
|
my $in = shift;
|
||||||
|
|
||||||
if ($text eq $in) {
|
if ( $text eq $in ) {
|
||||||
ok();
|
ok();
|
||||||
} else {
|
} else {
|
||||||
fail('cmp failed', '');
|
fail( 'cmp failed', '' );
|
||||||
dbg(4, "\n\ntext = <<<$text>>>, in = <<<$in>>>\n\n");
|
dbg( 4, "\n\ntext = <<<$text>>>, in = <<<$in>>>\n\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ my $ret = '';
|
||||||
|
|
||||||
$ret = access( $repo, $user, $aa, $ref );
|
$ret = access( $repo, $user, $aa, $ref );
|
||||||
|
|
||||||
if ($ret =~ /DENIED/) {
|
if ( $ret =~ /DENIED/ ) {
|
||||||
print "$ret\n" unless $quiet;
|
print "$ret\n" unless $quiet;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ usage() if @ARGV;
|
||||||
my $user = $ENV{GL_USER} or _die "GL_USER not set";
|
my $user = $ENV{GL_USER} or _die "GL_USER not set";
|
||||||
my $ref = 'any';
|
my $ref = 'any';
|
||||||
|
|
||||||
print "hello $user, this is gitolite3 " . version() . " on git " . substr(`git --version`, 12) . "\n";
|
print "hello $user, this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
|
||||||
|
|
||||||
my $lr = lister_dispatch('list-repos');
|
my $lr = lister_dispatch('list-repos');
|
||||||
my $lm = lister_dispatch('list-members');
|
my $lm = lister_dispatch('list-members');
|
||||||
|
@ -27,7 +27,7 @@ my $lm = lister_dispatch('list-members');
|
||||||
for ( @{ $lr->() } ) {
|
for ( @{ $lr->() } ) {
|
||||||
my $perm = '';
|
my $perm = '';
|
||||||
for my $aa (qw(R W ^C)) {
|
for my $aa (qw(R W ^C)) {
|
||||||
my $ret = access($_, $user, $aa, $ref);
|
my $ret = access( $_, $user, $aa, $ref );
|
||||||
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
|
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
|
||||||
}
|
}
|
||||||
next unless $perm =~ /\S/;
|
next unless $perm =~ /\S/;
|
||||||
|
|
|
@ -103,11 +103,11 @@ the gitolite-admin repo).
|
||||||
sub post_compile {
|
sub post_compile {
|
||||||
usage() if ( not @_ or $_[0] eq '-h' );
|
usage() if ( not @_ or $_[0] eq '-h' );
|
||||||
|
|
||||||
run_subdir('post-compile', @_);
|
run_subdir( 'post-compile', @_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_command {
|
sub run_command {
|
||||||
run_subdir('commands', @_);
|
run_subdir( 'commands', @_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_subdir {
|
sub run_subdir {
|
||||||
|
|
|
@ -54,7 +54,7 @@ sub main {
|
||||||
my $user = $ENV{GL_USER} = shift @ARGV;
|
my $user = $ENV{GL_USER} = shift @ARGV;
|
||||||
|
|
||||||
# set up the repo and the attempted access
|
# set up the repo and the attempted access
|
||||||
my ( $verb, $repo ) = parse_soc(); # returns only for git commands
|
my ( $verb, $repo ) = parse_soc(); # returns only for git commands
|
||||||
sanity($repo);
|
sanity($repo);
|
||||||
$ENV{GL_REPO} = $repo;
|
$ENV{GL_REPO} = $repo;
|
||||||
my $aa = ( $verb =~ 'upload' ? 'R' : 'W' );
|
my $aa = ( $verb =~ 'upload' ? 'R' : 'W' );
|
||||||
|
@ -79,9 +79,9 @@ sub parse_soc {
|
||||||
|
|
||||||
if ( $soc =~ m(^(git-(?:upload|receive)-pack) '/?(.*?)(?:\.git)?'$) ) {
|
if ( $soc =~ m(^(git-(?:upload|receive)-pack) '/?(.*?)(?:\.git)?'$) ) {
|
||||||
# TODO git archive
|
# TODO git archive
|
||||||
my($verb, $repo) = ($1, $2);
|
my ( $verb, $repo ) = ( $1, $2 );
|
||||||
_die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT;
|
_die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT;
|
||||||
return ($verb, $repo);
|
return ( $verb, $repo );
|
||||||
}
|
}
|
||||||
|
|
||||||
# after this we should not return; caller expects us to handle it all here
|
# after this we should not return; caller expects us to handle it all here
|
||||||
|
@ -90,8 +90,8 @@ sub parse_soc {
|
||||||
_die "suspicious characters loitering about '$soc'" if $soc !~ $REMOTE_COMMAND_PATT;
|
_die "suspicious characters loitering about '$soc'" if $soc !~ $REMOTE_COMMAND_PATT;
|
||||||
|
|
||||||
my @words = split ' ', $soc;
|
my @words = split ' ', $soc;
|
||||||
if ($rc{COMMANDS}{$words[0]}) {
|
if ( $rc{COMMANDS}{ $words[0] } ) {
|
||||||
_system("gitolite", @words);
|
_system( "gitolite", @words );
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ $|++;
|
||||||
# can be called directly, or as a post-update hook. Since it ignores
|
# can be called directly, or as a post-update hook. Since it ignores
|
||||||
# arguments anyway, it hardly matters.
|
# arguments anyway, it hardly matters.
|
||||||
|
|
||||||
my $ab = `gitolite query-rc -n GL_ADMIN_BASE`;
|
my $ab = `gitolite query-rc -n GL_ADMIN_BASE`;
|
||||||
_warn("'keydir' not found in '$ab'"), exit if not -d "$ab/keydir";
|
_warn("'keydir' not found in '$ab'"), exit if not -d "$ab/keydir";
|
||||||
my $akfile = "$ENV{HOME}/.ssh/authorized_keys";
|
my $akfile = "$ENV{HOME}/.ssh/authorized_keys";
|
||||||
my $glshell = `gitolite query-rc -n GL_BINDIR` . "/gitolite-shell";
|
my $glshell = `gitolite query-rc -n GL_BINDIR` . "/gitolite-shell";
|
||||||
|
|
|
@ -9,21 +9,21 @@
|
||||||
sub sugar_script {
|
sub sugar_script {
|
||||||
my $lines = shift;
|
my $lines = shift;
|
||||||
|
|
||||||
my @out = @{ $lines };
|
my @out = @{$lines};
|
||||||
unshift @out, groupnames();
|
unshift @out, groupnames();
|
||||||
|
|
||||||
return \@out;
|
return \@out;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub groupnames {
|
sub groupnames {
|
||||||
my @out = ();
|
my @out = ();
|
||||||
my %members = ();
|
my %members = ();
|
||||||
for my $pk (`find ../keydir/ -name "*.pub"`) {
|
for my $pk (`find ../keydir/ -name "*.pub"`) {
|
||||||
next unless $pk =~ m(.*/([^/]+)/([^/]+)\.pub$);
|
next unless $pk =~ m(.*/([^/]+)/([^/]+)\.pub$);
|
||||||
next if $1 eq 'keydir';
|
next if $1 eq 'keydir';
|
||||||
$members{$1} .= " $2";
|
$members{$1} .= " $2";
|
||||||
}
|
}
|
||||||
for my $m (sort keys %members) {
|
for my $m ( sort keys %members ) {
|
||||||
push @out, "\@$m =" . $members{$m};
|
push @out, "\@$m =" . $members{$m};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue