用SVN几个问题的解决

上一篇 / 下一篇  2014-06-06 17:29:03

1、svn->Show log 出现问题want to go offline

解决方法:在svnserve.conf 文件中,设置anon-access = none就可以了。

2、SVN如何强制在提交时要求添加注释说明 --windows平台

在库的hooks目录下,添加一个pre-commit.bat文件

内容如下(注意其中的SVN_BINDIR路径,可能需要改一下)

@echo off
rem SVN强制写注释的hooks脚本(Windows)
rem 文件名是: pre-commit.bat,放到repository/hooks目录下
setlocal
set SVN_BINDIR="C:\Program Files\CollabNet\Subversion Server"
set REPOS=%1
set TXN=%2
rem check that logmessage contains at least 10 characters
%SVN_BINDIR%\svnlook log "%REPOS%" -t "%TXN%" | findstr "......" > nul
if %errorlevel% gtr 0 goto err
exit 0
:err
echo 提交时必须填写注释(Message)! 1>&2
echo "%REPOS%" -t "%TXN%" 1>&2
exit 1

3、svn中限制上传文件大小的hooks

# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
#commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1

# All checks passed, so allow the commit.
#exit 0

#!/bin/sh
REPOS="$1"
TXN="$2"
RES="OK"
MAX_SIZE=10240000
FILTER='\.(zip|rar|o|obj|tar|gz)$'
 
# Make sure that the log message contains some text.
#SVNLOOK=/usr/bin/svnlook
SVNLOOK=/opt/CollabNet_Subversion/bin/svnlook

$SVNLOOK log -t "$TXN" "$REPOS" | egrep  "[^[:space:]]+" >/dev/null || unset RES 
if [ "$RES" != "OK" ]
then
echo "You must input some comments for you commit" >&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

4、综合

@echo
rem SVN强制写注释的hooks脚本(Windows)
rem 文件名是: pre-commit.bat,放到repository/hooks目录下
setlocal
set SVN_BINDIR="c:\Program Files\VisualSVN Server\bin"
set REPOS=%1
set TXN=%2

rem 检查是否提交日志
%SVN_BINDIR%\svnlook log -t "%TXN%" "%REPOS%" | findstr "......" > nul
if %errorlevel% gtr 0 goto nolog

rem 过滤文件类型
%SVN_BINDIR%\svnlook changed -t "%TXN%" "%REPOS%" | findstr "rar$"
if %errorlevel% EQU 0 (goto SuffixError)
%SVN_BINDIR%\svnlook changed -t "%TXN%" "%REPOS%" | findstr "zip$"
if %errorlevel% EQU 0 (goto SuffixError)
%SVN_BINDIR%\svnlook changed -t "%TXN%" "%REPOS%" | findstr "pptx$"
if %errorlevel% EQU 0 (goto SuffixError)
%SVN_BINDIR%\svnlook changed -t "%TXN%" "%REPOS%" | findstr "docx$"
if %errorlevel% EQU 0 (goto SuffixError)

exit 0
:SuffixError
echo 请不要提交受限制的文件类型,如:rar、zip、docx、pptx等等,谢谢! 1>&2
exit 1
:nolog
echo 日志(Message)是跟踪文档的重要信息,必须输入,不得输入无意义字符,长度不得小于6个字符。 1>&2
exit 1


TAG:

 

评分:0

我来说两句

日历

« 2024-04-17  
 123456
78910111213
14151617181920
21222324252627
282930    

我的存档

数据统计

  • 访问量: 5194
  • 日志数: 2
  • 建立时间: 2014-06-05
  • 更新时间: 2014-06-06

RSS订阅

Open Toolbar