On Tue, Jan 11, 2011 at 8:46 PM, David Xie <ddxie...@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
qazw...@gmail.com

Reply via email to