[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: Andy Levy <andy.levy_at_gmail.com>
Date: Wed, 13 May 2009 08:29:06 -0400

On Wed, May 13, 2009 at 07:09, Irfan Sayed <irfu.sayed_at_gmail.com> wrote:
> but i am just passing repository name to perl script. i can not pass
> transaction because i dont even know what is the transaction id being used
> at the time of commit.
> in pre-commit template $2 refers to the transaction but in perl script i can
> not write
> $txn = "$ARGV[1]"; beacsue i am not passing any transation id which i dont
> even know.

If you have set things up properly (name it just pre-commit, chmod +x
it), the script you provided in your email *is* the hook script, so
you can use $ARGV[] just fine. Subversion passes the transaction ID
(and repository path) - that's the whole point.

> On Wed, May 13, 2009 at 4:29 PM, Ryan Schmidt
> <subversion-2009b_at_ryandesign.com> wrote:
>>
>> 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=2236660

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-05-13 14:30:12 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.