Skip to content
Browse files

Reformat some code

  • Loading branch information...
1 parent 1d8dc74 commit ec19edba5148c022336f7efbe480287a52559d74 @gnustavo committed May 1, 2012
View
3 lib/SVN/Hooks.pm
@@ -45,8 +45,7 @@ sub run_hook {
if ($hook_name eq 'pre-commit') {
# The next arg is a transaction number
$repo_path = SVN::Look->new($repo_path, '-t' => $args[0]);
- }
- elsif ($hook_name =~ /^(?:post-commit|(?:pre|post)-revprop-change)$/) {
+ } elsif ($hook_name =~ /^(?:post-commit|(?:pre|post)-revprop-change)$/) {
# The next arg is a revision number
$repo_path = SVN::Look->new($repo_path, '-r' => $args[0]);
}
View
3 lib/SVN/Hooks/AllowLogChange.pm
@@ -62,8 +62,7 @@ sub ALLOW_LOG_CHANGE {
foreach my $who (@args) {
if (is_string($who) || is_rx($who)) {
push @Valid_Users, $who;
- }
- else {
+ } else {
croak "$HOOK: invalid argument '$who'\n";
}
}
View
9 lib/SVN/Hooks/AllowPropChange.pm
@@ -78,8 +78,7 @@ sub ALLOW_PROP_CHANGE {
foreach my $arg (@args) {
if (is_string($arg) || is_rx($arg)) {
push @whos, $arg;
- }
- else {
+ } else {
croak "$HOOK: invalid argument '$arg'\n";
}
}
@@ -108,15 +107,13 @@ sub pre_revprop_change {
my ($prop, $whos) = @$spec;
if (is_string($prop)) {
next if $propname ne $prop;
- }
- else {
+ } else {
next if $propname !~ $prop;
}
for my $who (@$whos) {
if (is_string($who)) {
return if $author eq $who;
- }
- else {
+ } else {
return if $author =~ $who;
}
}
View
3 lib/SVN/Hooks/CheckJira.pm
@@ -296,8 +296,7 @@ sub CHECK_JIRA {
if (ref $regex) {
push @Checks, [$regex => $opts];
- }
- else {
+ } else {
while (my ($opt, $val) = each %$opts) {
$Defaults{$opt} = $val;
}
View
3 lib/SVN/Hooks/CheckMimeTypes.pm
@@ -67,8 +67,7 @@ sub pre_commit {
my $props = $svnlook->proplist($added);
unless (my $mimetype = $props->{'svn:mime-type'}) {
push @errors, "property svn:mime-type is not set for: $added";
- }
- elsif ($mimetype =~ m:^text/:) {
+ } elsif ($mimetype =~ m:^text/:) {
for my $prop ('svn:eol-style', 'svn:keywords') {
push @errors, "property $prop is not set for text file: $added"
unless exists $props->{$prop};
View
17 lib/SVN/Hooks/CheckProperty.pm
@@ -100,23 +100,18 @@ sub pre_commit {
} elsif (is_value($what)) {
if (is_integer($what)) {
if ($what) {
- $is_set or push @errors, "property $prop must be set for: $added";
- }
- else {
+ $is_set or push @errors, "property $prop must be set for: $added";
+ } else {
$is_set and push @errors, "property $prop must not be set for: $added";
}
- }
- elsif (! $is_set) {
+ } elsif (! $is_set) {
push @errors, "property $prop must be set to \"$what\" for: $added";
- }
- elsif ($props->{$prop} ne $what) {
+ } elsif ($props->{$prop} ne $what) {
push @errors, "property $prop must be set to \"$what\" and not to \"$props->{$prop}\" for: $added";
}
- }
- elsif (! $is_set) {
+ } elsif (! $is_set) {
push @errors, "property $prop must be set and match \"$what\" for: $added";
- }
- elsif ($props->{$prop} !~ $what) {
+ } elsif ($props->{$prop} !~ $what) {
push @errors, "property $prop must match \"$what\" but is \"$props->{$prop}\" for: $added";
}
}
View
18 lib/SVN/Hooks/CheckStructure.pm
@@ -148,15 +148,13 @@ sub _check_structure {
if ($structure eq 'DIR') {
return (1) if @$path > 1;
return (0, "the component ($path->[0]) should be a DIR in");
- }
- elsif ($structure eq 'FILE') {
+ } elsif ($structure eq 'FILE') {
return (0, "the component ($path->[0]) should be a FILE in") if @$path > 1;
return (1);
} elsif (is_integer($structure)) {
return (1) if $structure;
return (0, "invalid path");
- }
- else {
+ } else {
return (0, "syntax error: unknown string spec ($structure), while checking");
}
} elsif (is_array_ref($structure)) {
@@ -173,30 +171,26 @@ sub _check_structure {
if (is_string($lhs)) {
if ($lhs eq $path->[0]) {
return _check_structure($rhs, $path);
- }
- elsif ($lhs =~ /^\d+$/) {
+ } elsif ($lhs =~ /^\d+$/) {
if ($lhs) {
return _check_structure($rhs, $path);
} elsif (is_string($rhs)) {
return (0, "$rhs, while checking");
- }
- else {
+ } else {
return (0, "syntax error: the right hand side of a number must be string, while checking");
}
}
} elsif (is_rx($lhs)) {
if ($path->[0] =~ $lhs) {
return _check_structure($rhs, $path);
}
- }
- else {
+ } else {
my $what = ref $lhs;
return (0, "syntax error: the left hand side of arrays in the structure spec must be scalars or qr/Regexes/, not $what, while checking");
}
}
return (0, "the component ($path->[0]) is not allowed in");
- }
- else {
+ } else {
my $what = ref $structure;
return (0, "syntax error: invalid reference to a $what in the structure spec, while checking");
}
View
3 lib/SVN/Hooks/JiraAcceptance.pm
@@ -158,8 +158,7 @@ sub pre_commit {
if (defined $Match) {
if ($jira_refs =~ $Match) {
$jira_refs = $1;
- }
- else {
+ } else {
chomp $jira_refs;
croak <<"EOS";
JIRA_ACCEPTANCE: Could not extract JIRA references from the log message.
View
18 lib/SVN/Hooks/UpdateConfFile.pm
@@ -172,8 +172,7 @@ sub UPDATE_CONF_FILE {
@$what > 0 or croak "$HOOK: $function argument must have at least one element.\n";
-x $what->[0] or croak "$HOOK: $function argument is not a valid command ($what->[0]).\n";
$confs{$function} = _functor($what);
- }
- else {
+ } else {
croak "$HOOK: $function argument must be a CODE-ref or an ARRAY-ref.\n";
}
@@ -182,10 +181,8 @@ sub UPDATE_CONF_FILE {
}
if (my $rotate = delete $args{rotate}) {
- $rotate =~ /^\d+$/
- or croak "$HOOK: rotate argument must be numeric, not '$rotate'";
- $rotate < 10
- or croak "$HOOK: rotate argument must be less than 10, not '$rotate'";
+ $rotate =~ /^\d+$/ or croak "$HOOK: rotate argument must be numeric, not '$rotate'";
+ $rotate < 10 or croak "$HOOK: rotate argument must be less than 10, not '$rotate'";
$confs{rotate} = $rotate;
}
@@ -209,8 +206,7 @@ sub pre_commit {
for my $file ($svnlook->added(), $svnlook->updated()) {
if (is_string($from)) {
next if $file ne $from;
- }
- else {
+ } else {
next if $file !~ $from;
}
@@ -245,8 +241,7 @@ sub post_commit {
my $to = $conf->{to};
if (is_string($from)) {
next if $file ne $from;
- }
- else {
+ } else {
next if $file !~ $from;
# interpolate backreferences
$to = eval qq{"$to"}; ## no critic
@@ -351,8 +346,7 @@ sub _functor {
local $ENV{SVNREPOPATH} = $svnlook->repo();
if (system("$cmd $temp/file $path $ENV{SVNREPOPATH} 1>$temp/output 2>$temp/error") == 0) {
return `cat $temp/output`;
- }
- else {
+ } else {
croak `cat $temp/error`;
}
};

0 comments on commit ec19edb

Please sign in to comment.
Something went wrong with that request. Please try again.