SVN::Hooks::CheckLog - Check log messages in commits.


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

Index


Code Index:

NAME

Top

SVN::Hooks::CheckLog - Check log messages in commits.

SYNOPSIS

Top

This SVN::Hooks plugin allows one to check if the log message in a 'svn commit' conforms to a Regexp.

It's active in the pre-commit hook.

It's configured by the following directive.

CHECK_LOG(REGEXP[, MESSAGE])

The REGEXP argument must be a qr/quoted regexp/ which must match the commit log messages. If it doesn't, then the commit is aborted.

The MESSAGE argument is an optional error message that is shown to the user in case the check fails.

	CHECK_LOG(qr/.../ => "The log message cannot be empty!");
	CHECK_LOG(qr/^\[(prj1|prj2|prj3)\]/
                  => "The log message must start with a project tag.");

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::CheckLog;

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

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

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

my @checks;

sub CHECK_LOG {
    my ($regexp, $error_message) = @_;

    defined $regexp and ref $regexp eq 'Regexp'
	or croak "$HOOK: first argument must be a qr/Regexp/\n";
    not defined $error_message or not ref $error_message
	or croak "$HOOK: second argument must be undefined, or a STRING\n";

    push @checks, {
	regexp => $regexp,
	error  => $error_message || "log message must match $regexp.",
    };

    PRE_COMMIT(\&pre_commit);

    return 1;
}

sub pre_commit {
    my ($svnlook) = @_;

    my $log = $svnlook->log_msg();

    foreach my $check (@checks) {
	$log =~ $check->{regexp}
	    or croak "$HOOK: $check->{error}";
    }

    return;
}

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