(perltidy)

This commit is contained in:
Sitaram Chamarty 2012-03-19 07:49:01 +05:30
parent d853c58ada
commit 24b36f11c5
5 changed files with 21 additions and 21 deletions

View file

@ -44,8 +44,8 @@ sub trace {
my $level = shift; return if $ENV{D} < $level; my $level = shift; return if $ENV{D} < $level;
my $args = ''; $args = join( ", ", @_ ) if @_; my $args = ''; $args = join( ", ", @_ ) if @_;
my $sub = ( caller 1 )[3] || ''; $sub =~ s/.*://; my $sub = ( caller 1 )[3] || ''; $sub =~ s/.*://;
if (not $sub) { if ( not $sub ) {
$sub = ( caller )[1]; $sub = (caller)[1];
$sub =~ s(.*/(.*))(($1)); $sub =~ s(.*/(.*))(($1));
} }
$sub .= ' ' x ( 32 - length($sub) ); $sub .= ' ' x ( 32 - length($sub) );
@ -72,7 +72,7 @@ sub _warn {
} }
sub _die { sub _die {
gl_log("_die:", @_); gl_log( "_die:", @_ );
if ( $ENV{D} and $ENV{D} >= 3 ) { if ( $ENV{D} and $ENV{D} >= 3 ) {
confess "FATAL: " . join( ",", @_ ) . "\n" if defined( $ENV{D} ); confess "FATAL: " . join( ",", @_ ) . "\n" if defined( $ENV{D} );
} elsif ( defined( $ENV{D} ) ) { } elsif ( defined( $ENV{D} ) ) {
@ -116,7 +116,7 @@ sub _system {
# run system(), catch errors. Be verbose only if $ENV{D} exists. If not, # run system(), catch errors. Be verbose only if $ENV{D} exists. If not,
# exit with <rc of system()> if it applies, else just "exit 1". # exit with <rc of system()> if it applies, else just "exit 1".
trace( 2, @_ ); trace( 2, @_ );
gl_log("_system:", @_); gl_log( "_system:", @_ );
if ( system(@_) != 0 ) { if ( system(@_) != 0 ) {
trace( 1, "system() failed", @_, "-> $?" ); trace( 1, "system() failed", @_, "-> $?" );
if ( $? == -1 ) { if ( $? == -1 ) {
@ -212,35 +212,35 @@ sub cleanup_conf_line {
# generate a timestamp. If a template is passed generate a log file name # generate a timestamp. If a template is passed generate a log file name
# based on it also # based on it also
sub gen_ts_lfn { sub gen_ts_lfn {
my ($s, $min, $h, $d, $m, $y) = (localtime)[0..5]; my ( $s, $min, $h, $d, $m, $y ) = (localtime)[ 0 .. 5 ];
$y += 1900; $m++; # usual adjustments $y += 1900; $m++; # usual adjustments
for ($s, $min, $h, $d, $m) { for ( $s, $min, $h, $d, $m ) {
$_ = "0$_" if $_ < 10; $_ = "0$_" if $_ < 10;
} }
my $ts = "$y-$m-$d.$h:$min:$s"; my $ts = "$y-$m-$d.$h:$min:$s";
return $ts unless @_; return $ts unless @_;
my($template) = shift; my ($template) = shift;
# substitute template parameters and set the logfile name # substitute template parameters and set the logfile name
$template =~ s/%y/$y/g; $template =~ s/%y/$y/g;
$template =~ s/%m/$m/g; $template =~ s/%m/$m/g;
$template =~ s/%d/$d/g; $template =~ s/%d/$d/g;
return ($ts, $template); return ( $ts, $template );
} }
sub gl_log { sub gl_log {
# the log filename and the timestamp come from the environment. If we get # the log filename and the timestamp come from the environment. If we get
# called even before they are set, we have no choice but to dump to STDERR # called even before they are set, we have no choice but to dump to STDERR
# (and probably call "logger"). # (and probably call "logger").
my $msg = join("\t", @_); my $msg = join( "\t", @_ );
my $ts = $ENV{GL_TS} || gen_ts_lfn(); my $ts = $ENV{GL_TS} || gen_ts_lfn();
my $fh; my $fh;
logger_plus_stderr("$ts no GL_LOGFILE env var", "$ts $msg") if not $ENV{GL_LOGFILE}; logger_plus_stderr( "$ts no GL_LOGFILE env var", "$ts $msg" ) if not $ENV{GL_LOGFILE};
open my $lfh, ">>", $ENV{GL_LOGFILE} or logger_plus_stderr("open log failed: $!", $msg); open my $lfh, ">>", $ENV{GL_LOGFILE} or logger_plus_stderr( "open log failed: $!", $msg );
print $lfh "$ts\t$msg\n"; print $lfh "$ts\t$msg\n";
close $lfh; close $lfh;
} }

View file

@ -199,13 +199,13 @@ sub new_wild_repo {
my ( $repo, $user ) = @_; my ( $repo, $user ) = @_;
_chdir( $rc{GL_REPO_BASE} ); _chdir( $rc{GL_REPO_BASE} );
trigger('PRE_CREATE', $repo, $user); trigger( 'PRE_CREATE', $repo, $user );
new_repo($repo); new_repo($repo);
_print( "$repo.git/gl-creator", $user ); _print( "$repo.git/gl-creator", $user );
_print( "$repo.git/gl-perms", "$rc{DEFAULT_ROLE_PERMS}\n" ) if $rc{DEFAULT_ROLE_PERMS}; _print( "$repo.git/gl-perms", "$rc{DEFAULT_ROLE_PERMS}\n" ) if $rc{DEFAULT_ROLE_PERMS};
# XXX git config, daemon, web... # XXX git config, daemon, web...
# XXX pre-create, post-create # XXX pre-create, post-create
trigger('POST_CREATE', $repo, $user); trigger( 'POST_CREATE', $repo, $user );
_chdir( $rc{GL_ADMIN_BASE} ); _chdir( $rc{GL_ADMIN_BASE} );
} }

View file

@ -183,9 +183,9 @@ sub role_names {
for my $line (@$lines) { for my $line (@$lines) {
if ( $line =~ /^(-|C|R|RW\+?(?:C?D?|D?C?)M?) (.* )?= (.+)/ ) { if ( $line =~ /^(-|C|R|RW\+?(?:C?D?|D?C?)M?) (.* )?= (.+)/ ) {
my($p, $r) = ($1, $2); my ( $p, $r ) = ( $1, $2 );
my $u = ''; my $u = '';
for (split ' ', $3) { for ( split ' ', $3 ) {
$_ = "\@$_" if $_ eq 'CREATOR' or $rc{ROLES}{$_}; $_ = "\@$_" if $_ eq 'CREATOR' or $rc{ROLES}{$_};
$u .= " $_"; $u .= " $_";
} }

View file

@ -29,7 +29,7 @@ sub update {
my $ret = access( $ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref ); my $ret = access( $ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref );
trace( 1, "access($ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref)", "-> $ret" ); trace( 1, "access($ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref)", "-> $ret" );
gl_log( 'update:check', $ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref, '->', $ret ); gl_log( 'update:check', $ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref, '->', $ret );
trigger('ACCESS_CHECK', $ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref, $ret); trigger( 'ACCESS_CHECK', $ENV{GL_REPO}, $ENV{GL_USER}, $aa, $ref, $ret );
_die $ret if $ret =~ /DENIED/; _die $ret if $ret =~ /DENIED/;
check_vrefs( $ref, $oldsha, $newsha, $oldtree, $newtree, $aa ); check_vrefs( $ref, $oldsha, $newsha, $oldtree, $newtree, $aa );

View file

@ -34,7 +34,7 @@ exit 0;
# XXX lots of stuff from gl-auth-command is missing for now... # XXX lots of stuff from gl-auth-command is missing for now...
sub in_local { sub in_local {
if ($ENV{SSH_ORIGINAL_COMMAND} =~ /git-\w+-pack/) { if ( $ENV{SSH_ORIGINAL_COMMAND} =~ /git-\w+-pack/ ) {
print STDERR "TRACE: gsh(", join( ")(", @ARGV ), ")\n"; print STDERR "TRACE: gsh(", join( ")(", @ARGV ), ")\n";
print STDERR "TRACE: gsh(SOC=$ENV{SSH_ORIGINAL_COMMAND})\n"; print STDERR "TRACE: gsh(SOC=$ENV{SSH_ORIGINAL_COMMAND})\n";
} }
@ -79,13 +79,13 @@ sub main {
my $ret = access( $repo, $user, $aa, 'any' ); my $ret = access( $repo, $user, $aa, 'any' );
trace( 1, "access($repo, $user, $aa, 'any')", "-> $ret" ); trace( 1, "access($repo, $user, $aa, 'any')", "-> $ret" );
gl_log( 'gitolite-shell:check', $repo, $user, $aa, 'any', '->', $ret ); gl_log( 'gitolite-shell:check', $repo, $user, $aa, 'any', '->', $ret );
trigger('ACCESS_CHECK', $repo, $user, $aa, 'any', $ret); trigger( 'ACCESS_CHECK', $repo, $user, $aa, 'any', $ret );
_die $ret if $ret =~ /DENIED/; _die $ret if $ret =~ /DENIED/;
$repo = "'$rc{GL_REPO_BASE}/$repo.git'"; $repo = "'$rc{GL_REPO_BASE}/$repo.git'";
trigger('PRE_GIT', $repo, $user, $aa, 'any', $verb); trigger( 'PRE_GIT', $repo, $user, $aa, 'any', $verb );
_system( "git", "shell", "-c", "$verb $repo" ); _system( "git", "shell", "-c", "$verb $repo" );
trigger('POST_GIT', $repo, $user, $aa, 'any', $verb); trigger( 'POST_GIT', $repo, $user, $aa, 'any', $verb );
} }
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------