I'm running SVN on a Windows server, and I'm using Perl scripts to implement some pre-commit hooks. I'm seeing the following error message from TortoiseSVN:
Error !!ScriptError!! Can't parse line: _U path/to/files/trunk
and this is the script:
foreach my $line (`$svnlook changed -t "$txn" "$repos"`)
{
chom开发者_Go百科p($line);
if ($line !~ /([AUD]).\s\s(.+)$/)
{
print STDERR "!!Script Error!! Can't parse line: $line\n";
exit(1);
}
else
{
# perform some actions
}
}
exit(0);
I tried replacing the regex with things like /_([AUD]).\s\s(.+)$/
with no sucess - I even tried /.*([AUD]).\s\s(.+)$/
.
Thoughts? Suggestions?
Without a look into the SVN documentation I'm just guessing:
In the output above only one space is shown between U and the actual path, but you have \s\s
in all your regexes.
[edit] Ok, now I had a look into the svnlook reference. First, your regex fails for current versions of svnlook, as the output is specified as follows:
- The first two columns contain the status
- the path starts at the fifth column
- Status may be one of A (added), U (content changed), D (deleted), _U (properties changes), and UU (content + properties changed)
So, you should be able to match with something like ^([_AUD]+)\s+(.+)$
. One can get more specific, but that ain't necessary.
If this doesn't match, please pipe the command's output to a file, and post the relevant part here.
if ($line !~ /^_?([AUD])\s+(.+)$/
should work fine.
精彩评论