You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by roger mills <ro...@gmail.com> on 2009/10/28 13:55:58 UTC
Unable to execute perl hooks
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");
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\n");
if ($cnr_number != "")
{
do blah blah
}
Can someone tell me what i am doing wrong here
Thanks
Roger
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2412122
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].
Re: Unable to execute perl hooks
Posted by Andrey Repin <an...@freemail.ru>.
Greetings, roger mills!
> 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
#!D:/perl/bin/perl
--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 28.10.2009, <19:49>
Sorry for my terrible english...
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2412182
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].
Re: Unable to execute perl hooks
Posted by roger mills <ro...@gmail.com>.
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 <ro...@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 <an...@gmail.com> wrote:
>
>> On Wed, Oct 28, 2009 at 09:55, roger mills <ro...@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@subversion.tigris.org].
Re: Unable to execute perl hooks
Posted by roger mills <ro...@gmail.com>.
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 <an...@gmail.com> wrote:
> On Wed, Oct 28, 2009 at 09:55, roger mills <ro...@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=2412138
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].
Re: Unable to execute perl hooks
Posted by Andy Levy <an...@gmail.com>.
On Wed, Oct 28, 2009 at 09:55, roger mills <ro...@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=2412124
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].