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

Re: pre commit trigger

From: Ryan Schmidt <subversion-2009b_at_ryandesign.com>
Date: Wed, 13 May 2009 05:59:12 -0500

On May 13, 2009, at 04:21, Irfan Sayed wrote:

> i tried both the things but still not working. please help
> here is my small script
>
> $svnlook = "/usr/bin/svnlook";
> $repo = "/usr/local/svn/projects";
> my @cmd = `$svnlook changed -t $2 $repo`;
> foreach(@cmd)
> {
> if ($_ =~/^A/)
> {
> print STDERR "added\n";
> exit 1;
> }
> else{
> print STDERR "not added\n";
> exit 1;
> }
> }
>
> this is just the sample simple script which i want to execute
> before commit. it is not giving any output when i add or midify any
> file

The example hook scripts in the template files are written in bash
syntax, but based on the above you appear to want to write a perl
script. That's fine, but in perl $2 is not how you refer to the
second command line argument; $ARGV[1] is. So the corrected script
would be:

#!/usr/bin/perl

$svnlook = "/usr/bin/svnlook";
$repo = "$ARGV[0]";
$txn = "$ARGV[1]";
my @cmd = `$svnlook changed -t $txn $repo`;
foreach(@cmd) {
        if ($_ =~/^A/) {
                print STDERR "added\n";
                exit 1;
        } else {
                print STDERR "not added\n";
                exit 1;
        }
}

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

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-05-13 13:00:35 CEST

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.