添加提交时必须写注释功能
1.进入相应工程的hooks目录下,例如我的仓库名是game,那我的目录就是/svnrepository/MicroGame/hooks,在这个下面找到pre-commit.tmpl文件,拷贝一份到当前目录,并去掉tmpl后缀,并设置其可执行权限chmod +x pre-commit
2.在pre-commit内添加脚本,其余脚本都注释掉
#svn调用脚本时传入的两个参数,REPOS仓库路径和TXN本次事务的事务号,REPOS为仓库根路径,不包含子目录
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 5 ]
then
echo -e "\n请填写日志,最少为5个字符!" 1>&2
exit 1
else
exit 0
fi
3.第二步为仓库所有目录都添加注释,如果要在指定目录添加注释,则需要使用svnlook dirs-changed:打印修改过的目录命令
REPOS="$1"
TXN="$2"
SPATH="test/doc"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
#此处指定为在已修改过的目录中匹配是否包含SPATH目录
FOUND=$($SVNLOOK dirs-changed "$REPOS" -t "$TXN" | grep -E "^$SPATH")
if [ "$LOGMSG" -lt 5 ] && [ "$FOUND" != "" ]
then
echo -e "\n请填写日志,最少为5个字符!" 1>&2
exit 1
else
exit 0
fi
新建项目功能
到svn根目录下执行命令
mkdir -p /svnrepository/project1
svnadmin create /svnrepository/project1
修改权限
在project1/conf/svnserve.conf中添加如下配置
[general]
anon-access = read
auth-access = write
password-db = /svnrepository/conf/passwd
authz-db = /svnrepository/conf/authz
realm = project1
在/svnrepository/conf/auzh中添加如下配置
[project1:/]
* = rw