r51282 - in /trunk/libsvn-hooks-perl: Changes META.yml README debian/changelog debian/control lib/SVN/Hooks.pm lib/SVN/Hooks/CheckJira.pm
angelabad-guest at users.alioth.debian.org
angelabad-guest at users.alioth.debian.org
Wed Jan 20 12:59:23 UTC 2010
Author: angelabad-guest
Date: Wed Jan 20 12:58:59 2010
New Revision: 51282
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=51282
Log:
New upstream release 0.25
Modified:
trunk/libsvn-hooks-perl/Changes
trunk/libsvn-hooks-perl/META.yml
trunk/libsvn-hooks-perl/README
trunk/libsvn-hooks-perl/debian/changelog
trunk/libsvn-hooks-perl/debian/control
trunk/libsvn-hooks-perl/lib/SVN/Hooks.pm
trunk/libsvn-hooks-perl/lib/SVN/Hooks/CheckJira.pm
Modified: trunk/libsvn-hooks-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsvn-hooks-perl/Changes?rev=51282&op=diff
==============================================================================
--- trunk/libsvn-hooks-perl/Changes (original)
+++ trunk/libsvn-hooks-perl/Changes Wed Jan 20 12:58:59 2010
@@ -1,4 +1,10 @@
Revision history for SVN-Hooks. -*- text -*-
+
+0.24 2010-01-19
+
+ Add a 'post_action' pseudo-check to CheckJira so that the
+ plugin can perform an action during the post-commit hook
+ phase.
0.24 2010-01-06
Modified: trunk/libsvn-hooks-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsvn-hooks-perl/META.yml?rev=51282&op=diff
==============================================================================
--- trunk/libsvn-hooks-perl/META.yml (original)
+++ trunk/libsvn-hooks-perl/META.yml Wed Jan 20 12:58:59 2010
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: SVN-Hooks
-version: 0.24
+version: 0.25
abstract: A framework for implementing Subversion hooks.
license: ~
author:
Modified: trunk/libsvn-hooks-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsvn-hooks-perl/README?rev=51282&op=diff
==============================================================================
--- trunk/libsvn-hooks-perl/README (original)
+++ trunk/libsvn-hooks-perl/README Wed Jan 20 12:58:59 2010
@@ -1,6 +1,6 @@
Name: SVN-Hooks
What: Framework for Subversion hooks
-Version: 0.24
+Version: 0.25
Author: Gustavo Chaves <gnustavo at cpan.org>
SVN-Hooks is a framework for creating Subversion hooks
Modified: trunk/libsvn-hooks-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsvn-hooks-perl/debian/changelog?rev=51282&op=diff
==============================================================================
--- trunk/libsvn-hooks-perl/debian/changelog (original)
+++ trunk/libsvn-hooks-perl/debian/changelog Wed Jan 20 12:58:59 2010
@@ -1,8 +1,11 @@
-libsvn-hooks-perl (0.24-2) UNRELEASED; urgency=low
+libsvn-hooks-perl (0.25-1) unstable; urgency=low
- * Update debhelper version (>= 7.0.8) for --with quilt use
+ * New upstream release
+ * debian/control:
+ - Remove perl from Depends
+ - Update debhelper version (>= 7.0.80) for --with quilt use
- -- Angel Abad <angelabad at gmail.com> Sat, 09 Jan 2010 14:07:57 +0100
+ -- Angel Abad <angelabad at gmail.com> Wed, 20 Jan 2010 13:58:20 +0100
libsvn-hooks-perl (0.24-1) unstable; urgency=low
Modified: trunk/libsvn-hooks-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsvn-hooks-perl/debian/control?rev=51282&op=diff
==============================================================================
--- trunk/libsvn-hooks-perl/debian/control (original)
+++ trunk/libsvn-hooks-perl/debian/control Wed Jan 20 12:58:59 2010
@@ -1,7 +1,7 @@
Source: libsvn-hooks-perl
Section: perl
Priority: optional
-Build-Depends: debhelper (>= 7.0.8), quilt (>= 0.46-7)
+Build-Depends: debhelper (>= 7.0.80), quilt (>= 0.46-7)
Build-Depends-Indep: libemail-send-perl,
libemail-simple-perl (>= 2.100) | libemail-simple-creator-perl,
libjira-client-perl, libsoap-lite-perl, libsvn-look-perl, libsvn-notify-perl,
@@ -21,7 +21,7 @@
Depends: ${misc:Depends}, ${perl:Depends}, libemail-send-perl,
libemail-simple-perl (>= 2.100) | libemail-simple-creator-perl,
libjira-client-perl, libsoap-lite-perl, libsvn-look-perl, libsvn-notify-perl,
- perl, subversion
+ subversion
Description: framework for implementing subversion hooks
SVN::Hooks is a framework for creating Subversion hooks. It comes with
a bunch of plugins (actually, sub-modules of SVN::Hooks) that
Modified: trunk/libsvn-hooks-perl/lib/SVN/Hooks.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsvn-hooks-perl/lib/SVN/Hooks.pm?rev=51282&op=diff
==============================================================================
--- trunk/libsvn-hooks-perl/lib/SVN/Hooks.pm (original)
+++ trunk/libsvn-hooks-perl/lib/SVN/Hooks.pm Wed Jan 20 12:58:59 2010
@@ -15,11 +15,11 @@
=head1 VERSION
-Version 0.24
+Version 0.25
=cut
-our $VERSION = '0.24';
+our $VERSION = '0.25';
=head1 SYNOPSIS
Modified: trunk/libsvn-hooks-perl/lib/SVN/Hooks/CheckJira.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsvn-hooks-perl/lib/SVN/Hooks/CheckJira.pm?rev=51282&op=diff
==============================================================================
--- trunk/libsvn-hooks-perl/lib/SVN/Hooks/CheckJira.pm (original)
+++ trunk/libsvn-hooks-perl/lib/SVN/Hooks/CheckJira.pm Wed Jan 20 12:58:59 2010
@@ -25,7 +25,7 @@
by an hyfen from a sequence of digits. E.g., CDS-123, RT-1, and
SVN-97.
-It's active in the C<pre-commit> hook.
+It's active in the C<pre-commit> and/or the C<post-commit> hook.
It's configured by the following directives.
@@ -144,6 +144,17 @@
objects for every referenced issue. The subroutine must simply return
with no value to indicate success and must die to indicate failure.
+=item post_action => CODE-REF
+
+This is not a check, but an opportunity to perform some action after a
+successful commit. The code reference passed will be called once
+during the post-commit hook phase. Its first argument is the
+JIRA::Client object used to talk to the JIRA server. The second
+argument is the SVN::Look object that can be used to inspect all the
+information about the commit proper. The following arguments are the
+JIRA keys mentioned in the commit log message. The value returned by
+the routine, if any, is ignored.
+
=back
You can set defaults for these options using a CHECK_JIRA directive
@@ -174,6 +185,33 @@
CHECK_JIRA(default => {projects => 'CDS'});
CHECK_JIRA(qr/./);
+
+The C<'post_action'> pseudo-check can be used to interact with the
+JIRA server after a successful commit. For instance, you may want to
+add a comment to each refered issue like this:
+
+ # This routine returns a closure that can be passed to
+ # post_action. The closure receives a string to be added as a
+ # comment to each issue refered to by the commit message. The
+ # commit info can be interpolated inside the comment using the
+ # SVN::Look method names inside angle brackets.
+
+ sub add_comment {
+ my ($format) = @_;
+ return sub {
+ my ($jira, $svnlook, @keys) = @_;
+ # Substitute keywords in the input comment with calls
+ # into the $svnlook reference
+ $format =~ s/\{(\w+)\}/"\$svnlook->$1()"/eeg;
+ for my $key (@keys) {
+ $jira->addComment($key, $format);
+ }
+ }
+ }
+
+ CHECK_JIRA(qr/./ => {
+ post_action => add_comment("Subversion Commit r{rev} by {author} on {date}\n{log_msg}")
+ });
=cut
@@ -207,6 +245,7 @@
by_assignee => \&_validate_bool,
check_one => \&_validate_code,
check_all => \&_validate_code,
+ post_action => \&_validate_code,
);
sub CHECK_JIRA {
@@ -232,6 +271,7 @@
}
}
$conf->{'pre-commit'} = \&pre_commit;
+ $conf->{'post-commit'} = \&post_commit if exists $opts->{post_action};
return 1;
}
@@ -248,32 +288,14 @@
};
};
-sub _check_jira {
- my ($self, $svnlook, $opts) = @_;
-
- my $conf = $self->{conf}
- or croak "$HOOK: plugin not configured. Please, use the CHECK_JIRA_CONFIG directive.\n";
-
- # Grok the JIRA issue keys from the commit log
- my ($match) = ($svnlook->log_msg() =~ $conf->{match});
- my @keys = defined $match ? $match =~ /\b[A-Z]+-\d+\b/g : ();
-
- if ($opts->{require}) {
- croak "$HOOK: you must cite at least one JIRA issue key in the commit message.\n"
- unless @keys;
- }
-
- return unless @keys;
-
- # Connect to JIRA if not yet connected.
- unless (exists $conf->{jira}) {
- $conf->{jira} = eval {JIRA::Client->new(@{$conf->{conf}})};
- croak "CHECK_JIRA_CONFIG: cannot connect to the JIRA server: $@\n" if $@;
- }
+sub _pre_checks {
+ my ($self, $svnlook, $keys, $opts) = @_;
+
+ my $conf = $self->{conf};
# Grok and check each JIRA issue
my @issues;
- foreach my $key (@keys) {
+ foreach my $key (@$keys) {
my $issue = eval {$conf->{jira}->getIssue($key)};
if ($opts->{valid}) {
croak "$HOOK: issue $key is not valid: $@\n" if $@;
@@ -301,23 +323,67 @@
return;
}
+sub _post_action {
+ my ($self, $svnlook, $keys, $opts) = @_;
+
+ if (my $action = $opts->{post_action}) {
+ $action->($self->{conf}->{jira}, $svnlook, @$keys);
+ }
+
+ return;
+}
+
+sub _check_if_needed {
+ my ($self, $svnlook, $docheck) = @_;
+
+ my $conf = $self->{conf}
+ or croak "$HOOK: plugin not configured. Please, use the CHECK_JIRA_CONFIG directive.\n";
+
+ my @files = $svnlook->changed();
+
+ foreach my $check (@{$self->{checks}}) {
+ my ($regex, $opts) = @$check;
+
+ for my $file (@files) {
+ if ($file =~ $regex) {
+
+ # Grok the JIRA issue keys from the commit log
+ my ($match) = ($svnlook->log_msg() =~ $conf->{match});
+ my @keys = defined $match ? $match =~ /\b[A-Z]+-\d+\b/g : ();
+
+ my %opts = (%{$self->{defaults}}, %$opts);
+
+ if ($opts{require}) {
+ croak "$HOOK: you must cite at least one JIRA issue key in the commit message.\n"
+ unless @keys;
+ }
+
+ return unless @keys;
+
+ # Connect to JIRA if not yet connected.
+ unless (exists $conf->{jira}) {
+ $conf->{jira} = eval {JIRA::Client->new(@{$conf->{conf}})};
+ croak "CHECK_JIRA_CONFIG: cannot connect to the JIRA server: $@\n" if $@;
+ }
+
+ $docheck->($self, $svnlook, \@keys, \%opts);
+ last;
+ }
+ }
+ }
+
+ return;
+}
+
sub pre_commit {
my ($self, $svnlook) = @_;
-
- my @files = $svnlook->changed();
-
- foreach my $check (@{$self->{checks}}) {
- my ($regex, $opts) = @$check;
-
- for my $file (@files) {
- if ($file =~ $regex) {
- my %opts = (%{$self->{defaults}}, %$opts);
- _check_jira($self, $svnlook, \%opts);
- last;
- }
- }
- }
-
+ _check_if_needed($self, $svnlook, \&_pre_checks);
+ return;
+}
+
+sub post_commit {
+ my ($self, $svnlook) = @_;
+ _check_if_needed($self, $svnlook, \&_post_action);
return;
}
More information about the Pkg-perl-cvs-commits
mailing list