You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Phil Pinkerton <pc...@gmail.com> on 2009/09/24 19:37:34 UTC

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

Develop a pre-commit hook script with the following action:

if filename extension = ".mdb" then
   if filename.size > 1mb then
          CANCEL COMMIT
          END of script
       end if
    end if
end if
Complete COMMIT

This is required to avoid placing Access databases into the repository that
might contain unwanted test data or have not been compacted and cleaned
first.

This will avoid the commitment of millions of bytes of worthless data in the
repository, increasing its size and slowing down the execution of
Subversion.


-- 
" 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=2399964

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by Phil Pinkerton <pc...@gmail.com>.
for now lets say the final file size has a 1MB limit. I imagine the
pre-commit could be modified later if the size is too small.

On Thu, Sep 24, 2009 at 4:00 PM, Andy Levy <an...@gmail.com> wrote:

> On Thu, Sep 24, 2009 at 15:55, Phil Pinkerton <pc...@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.
>
> Do you want the "final" size, or the committed size?
>
> IOW, what happens if someone commits an 800KB MDB file...then a 150KB
> change...then a 200KB change?
>
> The sizes of the individual changes are within your limit, but not the
> final file.
>
> > On Thu, Sep 24, 2009 at 3:49 PM, Andy Levy <an...@gmail.com> wrote:
> >>
> >> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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.
> >
> >
>



-- 
" 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=2399977

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by Andy Levy <an...@gmail.com>.
On Thu, Sep 24, 2009 at 15:55, Phil Pinkerton <pc...@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.

Do you want the "final" size, or the committed size?

IOW, what happens if someone commits an 800KB MDB file...then a 150KB
change...then a 200KB change?

The sizes of the individual changes are within your limit, but not the
final file.

> On Thu, Sep 24, 2009 at 3:49 PM, Andy Levy <an...@gmail.com> wrote:
>>
>> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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.
>
>

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

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by Phil Pinkerton <pc...@gmail.com>.
Unix ( Solaris server )

Thanks I'll play around with the script we have a sandbox to  play in only
difference is it has SVN 1.6.5 and Production is still running 1.4.3 ( soon
to be upgraded t0 1.6.5 )

On Thu, Sep 24, 2009 at 4:26 PM, David Weintraub <qa...@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 <pc...@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 <an...@gmail.com> wrote:
>>
>>> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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@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=2400223

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by Phil Pinkerton <pc...@gmail.com>.
On Fri, Sep 25, 2009 at 12:27 PM, Phil Pinkerton <pc...@gmail.com>wrote:

> 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 <qa...@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 <pc...@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 <an...@gmail.com> wrote:
>>>
>>>> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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@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.
>
>  Figured it out here it is:

REPOS=$1
TXN=$2

      svnlook changed -t ${TXN} ${REPOS} | while read FLAG FILE

      do
  #Skip the files unless they end in .mdb this way only .mdb files will be
limited to 1MB
        [ ${FILE##*.} != "mdb" ] && continue

        if [ $(svnlook cat -t${TXN} ${REPOS} "${FILE}" | wc -c) -ge 1000000
]
         then
echo ["$FILE"" is > 1MB ":"We can't commit Access databases larger than
1MB"] >&2
          exit 2
         fi

     done

     exit 0



-- 
" 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=2401317

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by Phil Pinkerton <pc...@gmail.com>.
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 <qa...@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 <pc...@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 <an...@gmail.com> wrote:
>>
>>> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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@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@subversion.tigris.org].

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

Posted by David Weintraub <qa...@gmail.com>.
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 <pc...@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 <an...@gmail.com> wrote:
>
>> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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@gmail.com

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

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by Phil Pinkerton <pc...@gmail.com>.
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 <an...@gmail.com> wrote:

> On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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.

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

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by Andy Levy <an...@gmail.com>.
On Thu, Sep 24, 2009 at 15:46, David Weintraub <qa...@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.

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

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

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

Posted by David Weintraub <qa...@gmail.com>.
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.
You should also not exit the commit script immediately. Instead, go through
all the files to be committed, and store all the errors (file name and
reason for the rejection) in an array. Then when you finish looping through
all the files, check to see if you have any errors. If you do, print them
all out and cancel the commit.

That way, if someone has a half dozen files that cannot be committed,
they'll see all the errors at once and can fix them all before doing a
second commit. Otherwise, they'll fix the first error, commit, see that
there's an other error, fix that one, commit again, etc.

On Thu, Sep 24, 2009 at 3:37 PM, Phil Pinkerton <pc...@gmail.com>wrote:

> Develop a pre-commit hook script with the following action:
>
> if filename extension = ".mdb" then
>    if filename.size > 1mb then
>           CANCEL COMMIT
>           END of script
>        end if
>     end if
> end if
> Complete COMMIT
>
> This is required to avoid placing Access databases into the repository that
> might contain unwanted test data or have not been compacted and cleaned
> first.
>
> This will avoid the commitment of millions of bytes of worthless data in
> the repository, increasing its size and slowing down the execution of
> Subversion.
>
>
> --
> " 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@gmail.com

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

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].