[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Unable to execute perl hooks

From: roger mills <rogermillsg_at_gmail.com>
Date: Wed, 28 Oct 2009 11:04:00 -0400

Resolved
You have to have -t in the svnlook log command. For testing -r
This the modified script that works

#!D:\perl\bin\perl
use strict;
use warnings;
my $debugEnabled = 0;
my $argNum = 0;
my ($repo_path, $txn_name) = @ARGV;
## Check to see if debug is enabled
##
foreach $argNum (0 .. $#ARGV)
{
  if ( ($ARGV[$argNum] eq "-d") || ($ARGV[$argNum] eq "-D"))
  {
    $debugEnabled = 1;
  }
}
if ($debugEnabled)
{
  print "\n------ DEBUG IS ENABLED ------\n";
  ## Use revision numbers since there is not a transaction number
  $txn_name = "-r $txn_name";
}
else
{
  ## Use transaction numbers
  $txn_name = "-t $txn_name";
}

my $svnlook = "D:\\Subversion\\bin\\svnlook.exe";

my $committer = `$svnlook author $txn_name $repo_path`
    or die("Unable to get committer with svnlook.\n");
chomp($committer);
print "$committer";
my $commitlog = `$svnlook log $txn_name $repo_path`
    or die("Unable to get log message with svnlook.\n");
print "$commitlog";
my ($cnr_number) = $commitlog =~ /^(CNR[0-9]+)/m
   or die("Enter a valid CNR Number. The Log Message has to start with a CNR
Number e.g. CNR12345\n");
print "$cnr_number";
if ($cnr_number != "")
{
print "do blah blah";
}

On Wed, Oct 28, 2009 at 10:40 AM, roger mills <rogermillsg_at_gmail.com> wrote:

> No i am calling the perl hook from a pre-commit.bat like this
> perl D:\apps\check.pl %1 %2
> if errorlevel 1 goto :ERROR
> exit 0
> :ERROR
> echo Error found in commit 1>&2
> exit 1
>
> I am trying to test the hooks script from the command line like this
> check.pl D:\SVN\CNR_Repository -- 54
> it will print the author
> rmills
>
> but not the log message
>
> On Wed, Oct 28, 2009 at 10:06 AM, Andy Levy <andy.levy_at_gmail.com> wrote:
>
>> On Wed, Oct 28, 2009 at 09:55, roger mills <rogermillsg_at_gmail.com> wrote:
>> > Hi
>> >
>> > I am new to Subversion so bear with me if this is a stupid question. I
>> am
>> > writing a subversion hook script in perl. The script will check the log
>> > message at commit and get the issue ID (e.g. CNR12345) from the message,
>> if
>> > the issue ID is not found in the log message it will block the commit
>> else
>> > move on and execute some sql query to the issue tracking database.
>> svnlook
>> > fails to get the log message but is successful in getting the author.
>> > #!D:\perl\bin\perl
>> > use strict;
>> > use warnings;
>> > my ($txn_name, $repo_path) = @ARGV;
>> > my $svnlook = "D:\\Subversion\\bin\\svnlook.exe";
>> > my $committer = `$svnlook author $txn_name $repo_path`
>> > or die("Unable to get committer with svnlook.\n");
>>
>> I'm cutting off your script here because it points out the crux of the
>> problem. You're running on Windows. On Windows, Subversion hooks must
>> be EXE, BAT or CMD files (the source specifically looks for these
>> extensions because they don't require an inter. A Perl script will not
>> execute directly.
>>
>> The workaround is to create a pre-commit.bat calls the Perl
>> interpreter & script, and passes the arguments (%1, %2, etc.) into the
>> Perl script. It'll also have to pass anything returned by your script
>> back to the user.
>>
>
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2412151

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-10-28 16:06:59 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.