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

Re: pre-commit hook script to avoid unwanted. to complex ?

From: Phil Pinkerton <pcpinkerton_at_gmail.com>
Date: Fri, 25 Sep 2009 12:27:55 -0400

Seems svnlook -t cat is having a problem returns error 1 on the command line
and error 255 when using TortoiseSVN 1.6.5 ?

On Thu, Sep 24, 2009 at 4:26 PM, David Weintraub <qazwart_at_gmail.com> wrote:

> Ah! I thought this was some sort of VB script since I didn't recognize the
> syntax.
> Are you on a Unix/Linux system? I can give you something fairly rough for
> shell scripting. This is not tested and my syntax willnot be 100% correct,
> but it gives you an idea what a pre-commit hook would look like:
>
> REPOS=$1TX=$2
> typeset -a
> # I use the svnlook changed to get a list of all the files changed
> /usr/bin/svnlook changed -t$TX $REPOS | while read type file
> do
> # I skill all the files unless they end in .mdb
> [ ${file##*.} != "mdb" ] && continue #Skip unless a .mdb suffix
> # I cat out the file and then count the characters.
> # If it is greater than 1mb, I put it in my error array.
> # Is there a better way to get the size of a file w/ svnlook?
> if [ $(/usr/bin/svnlook cat -t$TX $REPOS $file| wc -c) -ge "1000000" ]
> then
> $error["$file"]=""$file: We can't commit Access databases larger
> than 1mb"
> fi
> done
>
> # I'm done with the loop. Now see if I have any errors
> if [ ${#error[*]} -gt 0 ]
> then
> # If I have an error, I print to STDERR a comment
> # And then list all the files and why they were rejected
> echo "ERRORS in commit!" 1>&2
> foreach error in $error[*]
> do
> echo "$error" 1>&2
> done
> # Now I've finished my error message, exit with a
> # non-zero value. That lets Subversion know this
> # pre-commit hook failed
> exit 2
> fi
> # No errors. Exit with an exit value of zero, so Subversion
> # will commit this transaction.
> exit 0
>
>
> On Thu, Sep 24, 2009 at 3:55 PM, Phil Pinkerton <pcpinkerton_at_gmail.com>wrote:
>
>> Sorry for the lame explanation. I need a pre-commit script for a
>> subversion repository that follows the logic of the syntax.
>>
>> The question should have been:
>>
>> Is it possible to write a pre-commit script that accomplishes the example
>> syntax.
>>
>> On Thu, Sep 24, 2009 at 3:49 PM, Andy Levy <andy.levy_at_gmail.com> wrote:
>>
>>> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qazwart_at_gmail.com>
>>> wrote:
>>> > I take it this is written in VisualBasic? Not familiar with the syntax,
>>> but
>>> > that's pretty much how you'd do it. One comment is to print out
>>> something to
>>> > STDERR to explain why the commit failed. This should include the name
>>> of the
>>> > file rejected and the reason.
>>>
>>> I think it was meant as pseudocode for a solution to a question
>>> someone asked. Not sure what the exact question was though.
>>>
>>
>>
>>
>> --
>> " The fundamental principle here is that the justification for a physical
>> concept lies exclusively in its clear and unambiguous relation to the facts
>> that it can be experienced" AE
>>
>> Please Feed and Educate the Children... it's the least any of us can do.
>>
>>
>
>
> --
> David Weintraub
> qazwart_at_gmail.com
>

-- 
" The fundamental principle here is that the justification for a physical
concept lies exclusively in its clear and unambiguous relation to the facts
that it can be experienced"   AE
Please Feed and Educate the Children... it's the least any of us can do.
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2400311
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-09-25 18:28:59 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.