Hi. I couldn't find this in the archives.
I'm trying to create a pre-commit hook that only allows the commit of
Perl codes that pass the "perl -c" check. I have a initial version
(see below) that does exactly what I want IF the Perl code does not
use any customized module (.pm), because Perl can't find it when run
from the hook script.
Does anybody know how this could be done? I'm afraid that the hook
script would need to perform more tasks, like checking out the current
version of the path where the modules are located and then trying to
run "perl -c". Any ideas?
Thanks in advance,
-Marcos
- - - - - 8< - - - - -
#!/usr/bin/env perl -w
#
# pre-commit hook for Subversion
# deny commit of .pl and .pm Perl scripts if they don't pass the syntax check.
#
# under Windows, the contents of 'pre-commit.bat' should be:
# ...(repo path)...\hooks\pre-commit.pl %1 %2
#
$repos = shift;
$txn = shift;
# list files changed on this transaction
foreach $line (`svnlook changed -t $txn \"$repos\"`)
{
chomp($line);
if ($line !~ /^([AUD]).\s\s(.+)$/)
{
print STDERR "Can't parse [$line].\n";
exit(-1);
}
else
{
$action = $1;
$file = $2;
# check syntax of new or modified .pl and .pm Perl files with 'perl -c'
if (($file =~ /\.p[lm]$/) && ($action =~ /[AU]/))
{
system("svnlook cat -t $txn \"$repos\" \"$file\" | perl -c");
if ($? != 0)
{
print STDERR "\n$file does not pass the syntax check.";
exit(-1);
}
}
}
}
exit(0);
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Sep 14 20:33:39 2006