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

Re: SVN Hooks to require log message, limit size and file type

From: David Weintraub <qazwart_at_gmail.com>
Date: Wed, 12 Jan 2011 22:19:39 -0500

On Tue, Jan 11, 2011 at 8:46 PM, David Xie <ddxie.cn_at_gmail.com> wrote:
>
> Hello,
>
> I am looking for a hook to require log message when commit. I succeded to do it.
>
> At the same time, I want to limit size less than 10MB and forbid .zip .7z .rar file type.
> I found some hooks from internet, tried multi times but all failed. I could always
> commit big than 10M files and zip files. I struggled two days but could not resolve it.

I have a pre-commit hook at http://db.tt/H3o1i7S that will verify your
log message is at least 10 characters, and will also verify that your
files don't end in whatever suffixes you're trying to avoid. It
doesn't do a size check though.

Does your hook succeed in preventing files with your banned suffixes
from being committed? Is your problem just the size of the files? What
about comment length? Does your hook prevent people from writing
commit messages shorter than 10 characters?

After you calculate "filesize" add the following line:

echo "File size for $f is $filesize" 1>&2

Then, make the last line in your hook "exit 1" instead of "exit 0".

This will print out the file size of all the files you're attempting
to commit, and then fail the hook since the hook always exits with a
exit code of 1.

When you attempt to commit, you should see a failed commit and a bunch
of lines telling you the file size of each file. If not, you'll get a
better idea what the problem might be.

--
David Weintraub
qazwart_at_gmail.com
Received on 2011-01-13 04:20:17 CET

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.