r31700 - in /branches/upstream/libsvn-hooks-perl/current: ./ lib/SVN/ lib/SVN/Hooks/ t/
angelabad-guest at users.alioth.debian.org
angelabad-guest at users.alioth.debian.org
Sun Mar 8 13:52:52 UTC 2009
Author: angelabad-guest
Date: Sun Mar 8 13:52:43 2009
New Revision: 31700
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=31700
Log:
[svn-upgrade] Integrating new upstream version, libsvn-hooks-perl (0.14.38)
Modified:
branches/upstream/libsvn-hooks-perl/current/Changes
branches/upstream/libsvn-hooks-perl/current/META.yml
branches/upstream/libsvn-hooks-perl/current/README
branches/upstream/libsvn-hooks-perl/current/TODO
branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks.pm
branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/JiraAcceptance.pm
branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/UpdateConfFile.pm
branches/upstream/libsvn-hooks-perl/current/t/00-load.t
branches/upstream/libsvn-hooks-perl/current/t/02-allowlogchange.t
branches/upstream/libsvn-hooks-perl/current/t/02-checklog.t
branches/upstream/libsvn-hooks-perl/current/t/02-checkmimetypes.t
branches/upstream/libsvn-hooks-perl/current/t/02-checkproperty.t
branches/upstream/libsvn-hooks-perl/current/t/02-checkstructure.t
branches/upstream/libsvn-hooks-perl/current/t/02-denychanges.t
branches/upstream/libsvn-hooks-perl/current/t/02-denyfilenames.t
branches/upstream/libsvn-hooks-perl/current/t/02-jiraacceptance.t
branches/upstream/libsvn-hooks-perl/current/t/02-mailer.t
branches/upstream/libsvn-hooks-perl/current/t/02-notify.t
branches/upstream/libsvn-hooks-perl/current/t/02-updateconffile.t
branches/upstream/libsvn-hooks-perl/current/t/pod-coverage.t
branches/upstream/libsvn-hooks-perl/current/t/pod.t
branches/upstream/libsvn-hooks-perl/current/t/test-functions.pl
Modified: branches/upstream/libsvn-hooks-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/Changes?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/Changes (original)
+++ branches/upstream/libsvn-hooks-perl/current/Changes Sun Mar 8 13:52:43 2009
@@ -1,4 +1,21 @@
Revision history for SVN-Look. -*- text -*-
+
+0.14 2009-02-08
+
+ JiraAcceptance: don't replay the user's log in the error
+ message.
+
+ Removed LICENSE file because it was inconsistent with the
+ licensing information in META.yml.
+
+ UpdateConfFile:
+ - It accepts an 'actuator' function to be executed in the
+ post-commit hook after a succesful commit.
+ - All functions (validator, generator, and actuator) receive
+ the same two parameters: the file contents and the file
+ relative path in the repository.
+ - The files to be updated can be specified via Regexps and
+ they can be copied to subdirectories of /repo/conf.
0.13 2008-12-03
Modified: branches/upstream/libsvn-hooks-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/META.yml?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/META.yml (original)
+++ branches/upstream/libsvn-hooks-perl/current/META.yml Sun Mar 8 13:52:43 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: SVN-Hooks
-version: 0.13.12
+version: 0.14.38
abstract: A framework for implementing Subversion hooks.
license: ~
author:
Modified: branches/upstream/libsvn-hooks-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/README?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/README (original)
+++ branches/upstream/libsvn-hooks-perl/current/README Sun Mar 8 13:52:43 2009
@@ -1,6 +1,6 @@
Name: SVN-Hooks
What: Framework for Subversion hooks
-Version: 0.13
+Version: 0.14
Author: Gustavo Chaves <gnustavo at cpan.org>
SVN-Hooks is a framework for creating Subversion hooks
Modified: branches/upstream/libsvn-hooks-perl/current/TODO
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/TODO?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/TODO (original)
+++ branches/upstream/libsvn-hooks-perl/current/TODO Sun Mar 8 13:52:43 2009
@@ -4,7 +4,7 @@
sent by the Mailer plugin should be MIME compatible and specify
UTF-8 character encoding.
-* More than one configuration files
+* More than one configuration file
I implemented the possibility of having a list of configuration
files in order to be able to have a global configuration in
addition to the per-repository configuration. However, what I got
@@ -24,3 +24,13 @@
calling svnlook. However, another approach would be to implement an
option in svnlook to dump all information in a format like XML so
that we wouldn't need to call it several times.
+
+* Check the svnchecker project <http://svnchecker.tigris.org/> to see
+ if there is some interesting functionality there that is missing
+ here.
+
+* Allow for the configuration directives to be specified in the hook
+ script, to make it simpler in the simple cases.
+
+* Implement a clone of
+ http://svn.collab.net/viewvc/svn/trunk/contrib/hook-scripts/case-insensitive.py
Modified: branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks.pm?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks.pm (original)
+++ branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks.pm Sun Mar 8 13:52:43 2009
@@ -15,11 +15,11 @@
=head1 VERSION
-Version 0.13
+Version 0.14
=cut
-our $VERSION = '0.13.' . substr(q$Revision: 12 $, 10); # bump from 11
+our $VERSION = '0.14.' . (q$Revision: 38 $ =~ / (\d+) /)[0]; # bump from 36
=head1 SYNOPSIS
Modified: branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/JiraAcceptance.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/JiraAcceptance.pm?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/JiraAcceptance.pm (original)
+++ branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/JiraAcceptance.pm Sun Mar 8 13:52:43 2009
@@ -189,6 +189,9 @@
die "JIRA_ACCEPTANCE: Unable to connect to the JIRA server at \"$jira->{baseURL}/rpc/xmlrpc\": $@.\n"
if $@;
+ # This can happen if there's an error in the JIRA plugin
+ $result = 'false|JIRA internal error' unless defined $result;
+
my ($acceptance, $comment) = split '\|', $result;
$acceptance eq 'true'
Modified: branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/UpdateConfFile.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/UpdateConfFile.pm?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/UpdateConfFile.pm (original)
+++ branches/upstream/libsvn-hooks-perl/current/lib/SVN/Hooks/UpdateConfFile.pm Sun Mar 8 13:52:43 2009
@@ -3,8 +3,10 @@
use warnings;
use strict;
use SVN::Hooks;
+use File::Spec::Functions;
use File::Temp qw/tempdir/;
use Memoize;
+use Cwd qw/abs_path/;
use Exporter qw/import/;
my $HOOK = 'UPDATE_CONF_FILE';
@@ -35,9 +37,20 @@
=head2 UPDATE_CONF_FILE(FROM, TO, @ARGS)
-This directive tells that the file FROM kept under version control
-must be copied to TO, a directory relative to the C</repo/conf>
-directory in the server, after a succesful commit.
+This directive tells that after a succesful commit the file FROM, kept
+under version control, must be copied to TO.
+
+FROM can be a string or a qr/Regexp/ specifying the file path relative
+to the repository's root (e.g. "trunk/src/version.c").
+
+TO is a path relative to the C</repo/conf> directory in the server. It
+can be an explicit file name or a directory, in which case the
+basename of FROM is used as the name of the destination file.
+
+If FROM is a qr/Regexp/ TO is evaluated as a string in order to allow
+for the interpolation of capture buffers from the regular
+expression. This is useful to map the copy operation to a diferent
+directory structure, for example.
The optional @ARGS must be a sequence of pairs like these:
@@ -50,11 +63,36 @@
of FROM in the pre-commit hook to see if it's valid. If there is no
validator, the contents are considered valid.
+The function receives two string arguments: the contents of FROM and
+the relative path to FROM.
+
+The command is called with two arguments: the path to a temporary copy
+of FROM and the relative path to FROM.
+
=item generator => ARRAY or CODE
-A generator is a function or a command that will transform the
+A generator is a function or a command (specified by an array of
+strings that will be passed to the shell) that will transform the
contents of FROM in the post-commit hook before copying it to TO. If
there is no generator, the contents are copied as is.
+
+The function receives two string arguments: the contents of FROM and
+the relative path to FROM.
+
+The command is called with two arguments: the path to a temporary copy
+of FROM and the relative path to FROM.
+
+=item actuator => ARRAY or CODE
+
+An actuator is a function or a command (specified by an array of
+strings that will be passed to the shell) that will be invoked after a
+succesful commit of FROM in the post-commit hook.
+
+The function receives two string arguments: the contents of FROM and
+the relative path to FROM.
+
+The command is called with two arguments: the path to a temporary copy
+of FROM and the relative path to FROM.
=item rotate => NUMBER
@@ -70,21 +108,31 @@
'conf/authz' => 'authz',
validator => ['/usr/local/bin/svnauthcheck'],
generator => ['/usr/local/bin/authz-expand-includes'],
+ actuator => ['/usr/local/bin/notify-auth-change'],
rotate => 2,
);
UPDATE_CONF_FILE(
'conf/svn-hooks.conf' => 'svn-hooks.conf',
- validator => ['/usr/bin/perl', '-c'],
+ validator => [qw(/usr/bin/perl -c)],
+ actuator => sub {
+ my ($contents, $file) = @_;
+ die "Can't use Gustavo here." if $contents =~ /gustavo/;
+ },
rotate => 2,
);
+ UPDATE_CONF_FILE(
+ qr:/file(\n+)$:' => 'subdir/$1/file',
+ rotate => 2,
+ );
+
=cut
sub UPDATE_CONF_FILE {
my ($from, $to, @args) = @_;
- defined $from && ! ref $from
+ defined $from && (! ref $from || ref $from eq 'Regexp')
or die "$HOOK: invalid first argument.\n";
defined $to && ! ref $to
@@ -93,34 +141,32 @@
(@args % 2) == 0
or die "$HOOK: odd number of arguments.\n";
- if ($to =~ m:/:) {
- die "$HOOK: second argument must be a basename, not a path ($to).\n";
- }
- else {
- $to = $SVN::Hooks::Repo->{repo_path} . "/conf/$to";
- }
+ file_name_is_absolute($to)
+ and die "$HOOK: second argument cannot be an absolute pathname ($to).\n";
my $conf = $SVN::Hooks::Confs->{$HOOK};
- $conf->{confs}{$from}{to} = $to;
+ my %confs = (from => $from, to => $to);
+
+ push @{$conf->{confs}}, \%confs;
my %args = @args;
- for my $name (qw/validator generator/) {
- if (my $what = delete $args{$name}) {
+ for my $function (qw/validator generator actuator/) {
+ if (my $what = delete $args{$function}) {
if (ref $what eq 'CODE') {
- $conf->{confs}{$from}{$name} = $what;
+ $confs{$function} = $what;
}
elsif (ref $what eq 'ARRAY') {
# This should point to list of command arguments
@$what > 0
- or die "$HOOK: $name argument must have at least one element.\n";
+ or die "$HOOK: $function argument must have at least one element.\n";
-x $what->[0]
- or die "$HOOK: $name argument is not a valid command ($what->[0]).\n";
- $conf->{confs}{$from}{$name} = _functor($SVN::Hooks::Repo->{repo_path}, $what);
+ or die "$HOOK: $function argument is not a valid command ($what->[0]).\n";
+ $confs{$function} = _functor($SVN::Hooks::Repo->{repo_path}, $what);
}
else {
- die "$HOOK: $name argument must be a CODE-ref or an ARRAY-ref.\n";
+ die "$HOOK: $function argument must be a CODE-ref or an ARRAY-ref.\n";
}
$conf->{'pre-commit'} = \&pre_commit;
}
@@ -131,7 +177,7 @@
or die "$HOOK: rotate argument must be numeric, not '$rotate'";
$rotate < 10
or die "$HOOK: rotate argument must be less than 10, not '$rotate'";
- $conf->{confs}{$from}{rotate} = $rotate;
+ $confs{rotate} = $rotate;
}
keys %args == 0
@@ -148,18 +194,26 @@
my ($self, $svnlook) = @_;
CONF:
- while (my ($from, $conf) = each %{$self->{confs}}) {
+ foreach my $conf (@{$self->{confs}}) {
if (my $validator = $conf->{validator}) {
- for my $file (grep {$_ eq $from} $svnlook->added(), $svnlook->updated()) {
- my $text = $svnlook->cat($from);
+ my $from = $conf->{from};
+ for my $file ($svnlook->added(), $svnlook->updated()) {
+ if (! ref $from) {
+ next if $from ne $file;
+ }
+ else {
+ next if $from !~ $file;
+ }
+
+ my $text = $svnlook->cat($file);
if (my $generator = $conf->{generator}) {
- $text = eval { $generator->($text) };
+ $text = eval { $generator->($text, $file) };
defined $text
or die "$HOOK: Generator aborted for: $file\n", $@, "\n";
}
- my $validation = eval { $validator->($text) };
+ my $validation = eval { $validator->($text, $file) };
defined $validation
or die "$HOOK: Validator aborted for: $file\n", $@, "\n";
@@ -172,21 +226,50 @@
sub post_commit {
my ($self, $svnlook) = @_;
+ my $absbase = abs_path(catdir($SVN::Hooks::Repo->{repo_path}, 'conf'));
+
CONF:
- while (my ($from, $conf) = each %{$self->{confs}}) {
- for my $file (grep {$_ eq $from} $svnlook->added(), $svnlook->updated()) {
- my $text = $svnlook->cat($from);
+ foreach my $conf (@{$self->{confs}}) {
+ my $from = $conf->{from};
+ for my $file ($svnlook->added(), $svnlook->updated()) {
+ my $to = $conf->{to};
+ if (! ref $from) {
+ next if $file ne $from;
+ }
+ else {
+ next if $file !~ $from;
+ $to = eval qq{"$to"}; # interpolate backreferences
+ }
+
+ $to = abs_path(catfile($SVN::Hooks::Repo->{repo_path}, 'conf', $to));
+ if (-d $to) {
+ $to = catfile($to, (File::Spec->splitpath($file))[2]);
+ }
+
+ $absbase eq substr($to, 0, length($absbase))
+ or die <<"EOS";
+$HOOK: post-commit aborted for: $file
+
+This means that $file was committed but the associated
+configuration file wasn't generated because its specified
+location ($to)
+isn't below the repository's configuration directory
+($absbase).
+
+Please, correct the ${HOOK}'s second argument.
+EOS
+
+ my $text = $svnlook->cat($file);
if (my $generator = $conf->{generator}) {
- $text = eval { $generator->($text) };
- defined $text
- or die <<"EOS";
-$HOOK: Generator aborted for: $file
-
-This means that $file was commited but the associated
-configuration file wans't updated in the server:
-
- $conf->{to}
+ $text = eval { $generator->($text, $file) };
+ defined $text or die <<"EOS";
+$HOOK: generator in post-commit aborted for: $file
+
+This means that $file was committed but the associated
+configuration file wasn't generated in the server at:
+
+ $to
Please, investigate the problem and re-commit the file.
@@ -195,13 +278,32 @@
$@
EOS
}
-
- my $to = $conf->{to};
open my $fd, '>', "$to.new"
or die "$HOOK: Can't open file \"$to\" for writing: $!\n";
print $fd $text;
close $fd;
+
+ if (my $actuator = $conf->{actuator}) {
+ my $rc = eval { $actuator->($text, $file) };
+ defined $rc or die <<"EOS";
+$HOOK: actuator in post-commit aborted for: $file
+
+This means that $file was committed and the associated
+configuration file was generated in the server at:
+
+ $to
+
+But the actuator command that was called after the file generation
+didn't work right.
+
+Please, investigate the problem.
+
+Any error message produced by the actuator appears below:
+
+$@
+EOS
+ }
if (my $rotate = $conf->{rotate}) {
for (my $i=$rotate-1; $i >= 0; --$i) {
@@ -226,10 +328,11 @@
my $cmd = join(' ', @$cmdlist);
return sub {
- my ($text) = @_;
+ my ($text, $path) = @_;
my $temp = tempdir('UpdateConfFile.XXXXXX', TMPDIR => 1, CLEANUP => 1);
+ # FIXME: this is Unix specific!
open my $th, '>', "$temp/file"
or die "Can't create $temp/file: $!";
print $th $text;
Modified: branches/upstream/libsvn-hooks-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/00-load.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/00-load.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/00-load.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-allowlogchange.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-allowlogchange.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-allowlogchange.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-allowlogchange.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-checklog.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-checklog.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-checklog.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-checklog.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-checkmimetypes.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-checkmimetypes.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-checkmimetypes.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-checkmimetypes.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-checkproperty.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-checkproperty.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-checkproperty.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-checkproperty.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-checkstructure.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-checkstructure.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-checkstructure.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-checkstructure.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-denychanges.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-denychanges.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-denychanges.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-denychanges.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-denyfilenames.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-denyfilenames.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-denyfilenames.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-denyfilenames.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-jiraacceptance.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-jiraacceptance.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-jiraacceptance.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-jiraacceptance.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-mailer.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-mailer.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-mailer.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-mailer.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-notify.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-notify.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-notify.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-notify.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
@@ -7,11 +5,14 @@
require "test-functions.pl";
-if (eval {require SVN::Notify}) {
- plan tests => 1;
+if (not has_svn()) {
+ plan skip_all => 'Need svn commands in the PATH.';
+}
+elsif (! eval {require SVN::Notify}) {
+ plan skip_all => 'Need SVN::Notify.';
}
else {
- plan skip_all => 'Need SVN::Notify.';
+ plan tests => 1;
}
my $t = reset_repo();
Modified: branches/upstream/libsvn-hooks-perl/current/t/02-updateconffile.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/02-updateconffile.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/02-updateconffile.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/02-updateconffile.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use lib 't';
@@ -8,7 +6,7 @@
require "test-functions.pl";
if (has_svn()) {
- plan tests => 10;
+ plan tests => 13;
}
else {
plan skip_all => 'Need svn commands in the PATH.';
@@ -39,10 +37,10 @@
EOS
set_conf(<<'EOS');
-UPDATE_CONF_FILE('first', 'path/second');
+UPDATE_CONF_FILE('first', qr/regexp/);
EOS
-work_nok('second arg is path', 'UPDATE_CONF_FILE: second argument must be a basename, not a path', <<"EOS");
+work_nok('invalid second arg', 'UPDATE_CONF_FILE: invalid second argument', <<"EOS");
svn ci -mx $t/wc/file
EOS
@@ -74,7 +72,8 @@
UPDATE_CONF_FILE(file => 'file');
sub validate {
- my ($text) = @_;
+ my ($text, $file) = @_;
+ die "undefined second argument" unless defined $file;
if ($text =~ /abort/) {
die "Aborting!"
}
@@ -87,8 +86,9 @@
validator => \&validate);
sub generate {
- my ($text) = @_;
- return "[$text]\n";
+ my ($text, $file) = @_;
+ die "undefined second argument" unless defined $file;
+ return "[$file, $text]\n";
}
UPDATE_CONF_FILE(generate => 'generate',
@@ -117,9 +117,48 @@
svn add -q --no-auto-props $t/wc/generate
svn ci -mx $t/wc/generate
cat >$t/wc/generated <<'EOSS'
-[asdf
+[generate, asdf
]
EOSS
cmp $t/wc/generated $t/repo/conf/generate
EOS
+set_conf(<<'EOS');
+UPDATE_CONF_FILE(subfile => 'subdir');
+
+UPDATE_CONF_FILE(qr/^file(\d)$/ => '$1-file');
+
+sub actuate {
+ my ($text, $file) = @_;
+ die "undefined second argument" unless defined $file;
+ open F, '>', "/tmp/actuated" or die $!;
+ print F $text;
+ close F;
+}
+
+UPDATE_CONF_FILE(actuate => 'actuate',
+ actuator => \&actuate);
+EOS
+
+mkdir "$t/repo/conf/subdir";
+
+work_ok('to subdir', <<"EOS");
+echo asdf >$t/wc/subfile
+svn add -q --no-auto-props $t/wc/subfile
+svn ci -mx $t/wc/subfile
+cmp $t/wc/subfile $t/repo/conf/subdir/subfile
+EOS
+
+work_ok('regexp', <<"EOS");
+echo asdf >$t/wc/file1
+svn add -q --no-auto-props $t/wc/file1
+svn ci -mx $t/wc/file1
+cmp $t/wc/file1 $t/repo/conf/1-file
+EOS
+
+work_ok('actuate', <<"EOS");
+echo asdf >$t/wc/actuate
+svn add -q --no-auto-props $t/wc/actuate
+svn ci -mx $t/wc/actuate
+cmp $t/wc/actuate /tmp/actuated
+EOS
Modified: branches/upstream/libsvn-hooks-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/pod-coverage.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/pod-coverage.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/pod-coverage.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
use strict;
use warnings;
use Test::More;
Modified: branches/upstream/libsvn-hooks-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/pod.t?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/pod.t (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/pod.t Sun Mar 8 13:52:43 2009
@@ -1,5 +1,3 @@
-#!perl -T
-
use strict;
use warnings;
use Test::More;
Modified: branches/upstream/libsvn-hooks-perl/current/t/test-functions.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsvn-hooks-perl/current/t/test-functions.pl?rev=31700&op=diff
==============================================================================
--- branches/upstream/libsvn-hooks-perl/current/t/test-functions.pl (original)
+++ branches/upstream/libsvn-hooks-perl/current/t/test-functions.pl Sun Mar 8 13:52:43 2009
@@ -22,7 +22,6 @@
return 1;
}
-
our $T;
sub newdir {
@@ -46,8 +45,9 @@
sub work_ok {
my ($tag, $cmd) = @_;
- ok((do_script(newdir(), $cmd) == 0), $tag)
- or diag("work_ok command failed.\n");
+ my $dir = newdir();
+ ok((do_script($dir, $cmd) == 0), $tag)
+ or diag("work_ok command failed with following stderr:\n", `cat $dir/stderr`);
}
sub work_nok {
@@ -79,10 +79,17 @@
my ($text) = @_;
open my $fd, '>', "$T/repo/hooks/svn-hooks.pl"
or die "Can't create $T/repo/hooks/svn-hooks.pl: $!";
- print $fd <<'EOS';
-#!/usr/bin/perl
+ print $fd <<"EOS";
+#!$^X
use strict;
use warnings;
+EOS
+ if (defined $ENV{PERL5LIB}) {
+ foreach my $path (reverse split /:/, $ENV{PERL5LIB}) {
+ print $fd "use lib '$path';\n";
+ }
+ }
+ print $fd <<"EOS";
use lib 'blib/lib';
use SVN::Hooks;
EOS
More information about the Pkg-perl-cvs-commits
mailing list