Return-Path: Delivered-To: apmail-subversion-users-archive@minotaur.apache.org Received: (qmail 95825 invoked from network); 12 Jan 2011 01:47:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Jan 2011 01:47:28 -0000 Received: (qmail 84671 invoked by uid 500); 12 Jan 2011 01:47:27 -0000 Delivered-To: apmail-subversion-users-archive@subversion.apache.org Received: (qmail 84561 invoked by uid 500); 12 Jan 2011 01:47:27 -0000 Mailing-List: contact users-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@subversion.apache.org Received: (qmail 84554 invoked by uid 99); 12 Jan 2011 01:47:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 01:47:27 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ddxie.cn@gmail.com designates 209.85.213.171 as permitted sender) Received: from [209.85.213.171] (HELO mail-yx0-f171.google.com) (209.85.213.171) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 01:47:19 +0000 Received: by yxi11 with SMTP id 11so37379yxi.16 for ; Tue, 11 Jan 2011 17:46:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=mIB3UUXRsVSBrScrgXZ801AQ1JPc/qu/i3Xsrvf0GPc=; b=JjbxIgPcfJmLoWgyMYzbwhcNOH9gpTy2L1hi92VTpI9Ko8yul+QSb9iIV6TlNNZait 5PxqrFj2gteNAAMkdMfFuD/0pWcJN0U6Ksh/QiVenktCqpZjz3GY3Xj5AgfqxaB1eOhj G1lUvRpKv/j9iO4eWjy13dxY8kyryd/KUmrI4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ViP9nCfGctIe/fzRChV6Up8ttIF3x49HOUJ2kPSJ6sDbs2fXqnlvAialvCB6Yudj/n 4GMpRhmd/Jv9KiArhA63pTTgSlsEw4gMgL7V1RERaObSW34oN1NFak7FtmydEGsa1zu8 vnhnwcPI6xyIPskJ9jGQ0qY+s+Zd6ltAh7/e8= MIME-Version: 1.0 Received: by 10.151.110.10 with SMTP id n10mr1126540ybm.160.1294796818277; Tue, 11 Jan 2011 17:46:58 -0800 (PST) Received: by 10.150.51.14 with HTTP; Tue, 11 Jan 2011 17:46:58 -0800 (PST) Date: Wed, 12 Jan 2011 09:46:58 +0800 Message-ID: Subject: SVN Hooks to require log message, limit size and file type From: David Xie To: users@subversion.apache.org Content-Type: multipart/alternative; boundary=00151757463868e69b04999c609e X-Virus-Checked: Checked by ClamAV on apache.org --00151757463868e69b04999c609e Content-Type: text/plain; charset=UTF-8 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 post my pre-commit at the end. RHEL 5.3 SVN 1.6.15 Apache 2.2.14 Java 1.6.0_17 Would someone give me some help? Great thanks! Regards, David pre-commit : #!/bin/sh REPOS="$1" TXN="$2" MAX_SIZE=10240000 MIN_LOG=10 FILTER='\.(zip|rar|o|obj|tar|gz)$' SVNLOOK=/local/svnroot/subversion/bin/svnlook # Make sure that the log message contains some text. LOGMSG=$($SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c) if [ "$LOGMSG" -lt $MIN_LOG ] then echo -e "Please enter at least 10 characters for log message. Questions, contact David" >&2 exit 1 fi files=$($SVNLOOK changed -t $TXN $REPOS |awk '{print $2}') for f in $files do #check file type if echo $f|tr A-Z a-z|grep -Eq $FILTER then echo "File $f is not allow ($FILTER) file" >&2 exit 1 fi #check file size filesize=$($SVNLOOK cat -t $TXN $REPOS $f|wc -c) if [ "$filesize" -gt "$MAX_SIZE"] then echo "File $f is too large(must <=$MAX_SIZE)" >&2 exit 1 fi done #All checks passed, so allow the commit. exit 0 --00151757463868e69b04999c609e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello,
=C2=A0
I am looking for a hook to require log message whe= n commit. I succeded to do it.
=C2=A0
At the same time, I want to lim= it 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 commi= t big than 10M files and zip files. I struggled two days but could not reso= lve it.
=C2=A0
I=C2=A0post my pre-commit at the end.
RHEL 5.3
SVN 1.6.15Apache 2.2.14
Java 1.6.0_17
=C2=A0
Would=C2=A0someone give me so= me help? Great thanks!
=C2=A0=C2=A0
Regards,
David
=C2=A0
pre-commit :
#!/bin/sh
REPOS=3D"$1"
TXN=3D"$2"
MAX_SIZ= E=3D10240000
MIN_LOG=3D10
FILTER=3D'\.(zip|rar|o|obj|tar|gz)$'= ;
SVNLOOK=3D/local/svnroot/subversion/bin/svnlook
# Make sure that the log message contains some text.
LOGMSG=3D$($SV= NLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]&q= uot; | wc -c)
if [ "$LOGMSG" -lt $MIN_LOG ]
then
echo -e= "Please enter at least 10 characters for log message. Questions, cont= act David" >&2
exit 1
fi
=C2=A0
files=3D$($SVNLOOK changed -t $TXN $REPOS |awk '{print $2}')for f in $files
do

#check file type
if echo $f|tr A-Z a-z|grep -Eq $FILTER
then=
echo "File $f is not allow ($FILTER) file" >&2
exit= 1
fi
=C2=A0
#check file size
filesize=3D$($SVNLOOK cat -t $TXN $REPOS $f|wc -c)=
if [ "$filesize" -gt "$MAX_SIZE"]
then
echo &= quot;File $f is too large(must <=3D$MAX_SIZE)" >&2
exit 1=
fi

done
=C2=A0
#All checks passed, so allow the commit.
exit 0
=C2=A0
--00151757463868e69b04999c609e--