SVN::Hooks::CheckCapability - Check the svn client capabilities.


SVN-Hooks documentation Contained in the SVN-Hooks distribution.

Index


Code Index:

NAME

Top

SVN::Hooks::CheckCapability - Check the svn client capabilities.

SYNOPSIS

Top

This SVN::Hooks plugin checks if the Subversion client implements the required capabilities.

It's active in the start-commit hook.

It's configured by the following directive.

CHECK_CAPABILITY(CAPABILITY...)

This directive enables the checking, causing the commit to abort if it doesn't comply.

The arguments are a list of capability names. Every capability specified must be supported by the client in order to the hook to succeed.

Example:

	CHECK_CAPABILITY('mergeinfo');

AUTHOR

Top

Gustavo Chaves, <gnustavo@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-svn-hooks-checkproperty at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SVN-Hooks. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc SVN::Hooks

You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=SVN-Hooks

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/SVN-Hooks

* CPAN Ratings

http://cpanratings.perl.org/d/SVN-Hooks

* Search CPAN

http://search.cpan.org/dist/SVN-Hooks

COPYRIGHT & LICENSE

Top


SVN-Hooks documentation Contained in the SVN-Hooks distribution.
package SVN::Hooks::CheckCapability;

use strict;
use warnings;
use Carp;
use SVN::Hooks;

use Exporter qw/import/;
my $HOOK = 'CHECK_CAPABILITY';
our @EXPORT = ($HOOK);

our $VERSION = $SVN::Hooks::VERSION;

my @Capabilities;

sub CHECK_CAPABILITY {
    push @Capabilities, @_;

    START_COMMIT(\&start_commit);

    return 1;
}

sub start_commit {
    my ($repo_path, $user, $capabilities) = @_;

    $capabilities ||= ''; # pre 1.5 svn clients don't pass the capabilities

    # Create a hash to facilitate the checks
    my %supported;
    @supported{split /:/, $capabilities} = undef;

    # Grok which required capabilities are missing
    my @missing = grep {! exists $supported{$_}} @Capabilities;

    if (@missing) {
	croak "$HOOK: Your subversion client does not support the following capabilities:\n\n\t",
	    join(', ', @missing),
	    "\n\nPlease, consider upgrading to a newer version of your client.\n";
    }
}

1; # End of SVN::Hooks::CheckCapability