Dear Sir:
How do you do?
1.Environment description:
Visual SVN Server 2.7.13, installed on Windows Server 2007 SP2 operating system.
Now I create a version library named test. It works fine.
2.My needs:
I want to limit the size of the submitted files.
3.My operation:
1) I copy the file named pre-commit.tmpl and save it as file named pre-commit.sh in hooks directory.
2) Modify the file named pre-commit.sh as follows:
#!/bin/bash
REPOS="$1"
TXN="$2"
SVNLOOK="C:/Program Files/VisualSVN Server/bin/svnlook"
#SVNLOOK=/usr/bin/svnlook
MAX_SIZE=512000
files=$($SVNLOOK changed -t $TXN $REPOS | awk '{print $2}')
# check check
#if [[ $files =~ "project_nuli" ]];then
for f in $files
do
# 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)" >> /dev/stderr
exit 1
fi
done
#fi
exit 0
3) Restart the SVN service
4.actual result:
Then I submit a 46k file, but it succeeded. The new pre-commit hook seems not to work?
What’s wrong?
Fervently hope expert’s advice. Your early reply will be highly appreciated.
Thank you so much!
Yours
yipianlvye
June 30, 2018
How do you do?
1.Environment description:
Visual SVN Server 2.7.13, installed on Windows Server 2007 SP2 operating system.
Now I create a version library named test. It works fine.
2.My needs:
I want to limit the size of the submitted files.
3.My operation:
1) I copy the file named pre-commit.tmpl and save it as file named pre-commit.sh in hooks directory.
2) Modify the file named pre-commit.sh as follows:
#!/bin/bash
REPOS="$1"
TXN="$2"
SVNLOOK="C:/Program Files/VisualSVN Server/bin/svnlook"
#SVNLOOK=/usr/bin/svnlook
MAX_SIZE=512000
files=$($SVNLOOK changed -t $TXN $REPOS | awk '{print $2}')
# check check
#if [[ $files =~ "project_nuli" ]];then
for f in $files
do
# 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)" >> /dev/stderr
exit 1
fi
done
#fi
exit 0
3) Restart the SVN service
4.actual result:
Then I submit a 46k file, but it succeeded. The new pre-commit hook seems not to work?
What’s wrong?
Fervently hope expert’s advice. Your early reply will be highly appreciated.
Thank you so much!
Yours
yipianlvye
June 30, 2018
Comment