[Bps-public-commit] r9035 - in SVN-Hook: lib/SVN/Hook t
clkao at bestpractical.com
clkao at bestpractical.com
Thu Sep 13 10:51:42 EDT 2007
Author: clkao
Date: Thu Sep 13 10:51:37 2007
New Revision: 9035
Modified:
SVN-Hook/lib/SVN/Hook.pm
SVN-Hook/lib/SVN/Hook/CLI.pm
SVN-Hook/lib/SVN/Hook/Redispatch.pm
SVN-Hook/t/01basic.t
SVN-Hook/t/02partial.t
Log:
tidy up cli.
Modified: SVN-Hook/lib/SVN/Hook.pm
==============================================================================
--- SVN-Hook/lib/SVN/Hook.pm (original)
+++ SVN-Hook/lib/SVN/Hook.pm Thu Sep 13 10:51:37 2007
@@ -16,14 +16,10 @@
my $pre_commit = $hooks->scripts('pre-commit');
print $_->path."\n" for (@$pre_commit);
- # todo
- $hook->disable('pre-commit', 'random_check');
-
-
=head1 DESCRIPTION
C<SVN::Hook> provides a programmable interface to manage hook scripts
-for Subversion.
+for Subversion. See L<svnhook> for the CLI usage.
=cut
@@ -61,10 +57,12 @@
my $path = $self->hook_path($hook);
die "There is already $hook file.\n" if -e $path;
+ my $svnlook = $ENV{SVNLOOK} || 'svnlook';
$self->_install_perl_hook( $path, <<"EOF");
# Generated by svnhook version $VERSION.
# This $hook hook is managed by svnook.
+BEGIN { \$ENV{SVNLOOK} = "$svnlook" };
use SVN::Hook::Redispatch {
'' => '',
# Add other dispatch mapping here:
@@ -138,4 +136,44 @@
return $result;
}
+=head1 TODO
+
+=over
+
+=item *
+
+CLI to manage enable/disable scripts
+
+=item *
+
+CLI to display and dry-run for subdir scripts for redispatch
+
+=item *
+
+More tests and doc
+
+=back
+
+=head1 LICENSE
+
+Copyright 2007 Best Practical Solutions, LLC.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+=head1 AUTHORS
+
+Chia-liang Kao E<lt>clkao at bestpractical.com<gt>
+
+=cut
+
1;
Modified: SVN-Hook/lib/SVN/Hook/CLI.pm
==============================================================================
--- SVN-Hook/lib/SVN/Hook/CLI.pm (original)
+++ SVN-Hook/lib/SVN/Hook/CLI.pm Thu Sep 13 10:51:37 2007
@@ -5,7 +5,8 @@
sub dispatch {
my $class = shift;
- my $cmd = shift;
+ my $cmd = shift or die "$0 version $SVN::Hook::VERSION.\n";
+ die if $cmd =~ m/^_/;
my $func = $class->can($cmd) or die "no such command $cmd.\n";
$func->($class, @_);
@@ -13,8 +14,8 @@
sub run {
my $class = shift;
- my $repospath = shift;
- my $hook = shift;
+ my $repospath = shift or die "repository required.\n";
+ my $hook = shift or die "hook name required.\n";
unshift @_, $class, $hook, $repospath;
goto \&run;
}
@@ -31,9 +32,8 @@
sub init {
my $class = shift;
- my ($repospath, @hooks) = @_;
-
- @hooks = SVN::Hook->ALL_HOOKS unless @hooks;
+ my $repospath = shift or die "repository required.\n";
+ my @hooks = @_ ? @_ : SVN::Hook->ALL_HOOKS;
my $h = SVN::Hook->new({repospath => $repospath});
$h->init($_) for @hooks;
@@ -41,8 +41,9 @@
}
sub list {
- my $class = shift;
- my ($repospath, $hook) = @_;
+ my $class = shift;
+ my $repospath = shift or die "repository required.\n";
+ my $hook = shift or die "hook name required.\n";
my $h = SVN::Hook->new({repospath => $repospath});
my $i = 0;
@@ -55,7 +56,7 @@
sub status {
my $class = shift;
- my $repospath = shift;
+ my $repospath = shift or die "repository required.\n";
my $h = SVN::Hook->new({repospath => $repospath});
my $status = $h->status;
Modified: SVN-Hook/lib/SVN/Hook/Redispatch.pm
==============================================================================
--- SVN-Hook/lib/SVN/Hook/Redispatch.pm (original)
+++ SVN-Hook/lib/SVN/Hook/Redispatch.pm Thu Sep 13 10:51:37 2007
@@ -13,6 +13,9 @@
my $type;
my $svnlook_arg;
+ # $0 can be either hooks/_pre-commit/random_name or
+ # hooks/pre-commit itself
+
if ($hook_base->parent =~ m'hooks$') { # the hook file itself
my $type = $hook_base->basename;
$hook_base = $hook_base->parent->subdir("_".$type);
@@ -59,7 +62,7 @@
my $repos = shift;
my $arg = shift;
- my $svnlook = '/usr/local/bin/svnlook';
+ my $svnlook = $ENV{SVNLOOK} || 'svnlook';
open my $fh, '-|', "$svnlook dirs-changed $arg $repos"
or die "Unable to run svnlook: $!";
my $toplevel;
Modified: SVN-Hook/t/01basic.t
==============================================================================
--- SVN-Hook/t/01basic.t (original)
+++ SVN-Hook/t/01basic.t Thu Sep 13 10:51:37 2007
@@ -4,6 +4,10 @@
eval { use SVK::Test; 1 }
or plan skip_all => 'requires SVK for testing.';
+use SVK::Util 'can_run';
+$ENV{SVNLOOK} ||= can_run('svnlook')
+ or plan skip_all => 'requires svnlook testing.';
+
plan tests => 3;
use_ok('SVN::Hook');
Modified: SVN-Hook/t/02partial.t
==============================================================================
--- SVN-Hook/t/02partial.t (original)
+++ SVN-Hook/t/02partial.t Thu Sep 13 10:51:37 2007
@@ -3,7 +3,9 @@
use Test::More;
eval { use SVK::Test; 1 }
or plan skip_all => 'requires SVK for testing.';
-
+use SVK::Util 'can_run';
+$ENV{SVNLOOK} ||= can_run('svnlook')
+ or plan skip_all => 'requires svnlook testing.';
plan tests => 4;
use_ok('SVN::Hook');
use File::Temp 'tempdir';
More information about the Bps-public-commit
mailing list