Subversion svn配置

$ yum install svn #安装svn,如果是ubuntu,apt-get install subversion
$ svn #检查svn是否安装
$ cd /var/www/html/
$ mkdir test
$ cd /home
$ mkdir code
$ svnserve -d -r /home/code #启动svn服务
$ cd code
$ svnadmin create test
$ cd test
$ cd conf
$ vim svnserve.conf
#原来:
#anon-access = read
#auth-access = write
#password-db = passwd
#更改:
anon-access = none  #none不允许匿名访问
auth-access = write  #write允许授权读写
password-db = passwd

#新建post-commit提交svn自动同步文件
$ cd ../hooks/
$ vim post-commit
#修改
#!/bin/sh
REPOS="$1"
REV="$2"
export LANG=en_US.UTF-8
svn update /var/www/html/test--username super --password 123456 --no-auth-cache
$ chmod 755 post-commit
$ ./post-commit

#SVN强制写注释要求
$ vim pre-commit
#修改
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook

# check that logmessage contains at least 10 alphanumeric characters
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 5 ];
then
echo -e "Empty log message not allowed. Commit aborted!" 1>&2
exit 1
fi

成功…得瑟!!!

遇到问题:
1.直接在服务器端vim修改代码,导致服务器端与客户端svn不同步。解决方案:rm -rf 服务器端文件,然后在客户端再提交一次该文件。

p.s.特别感谢何总帮助

发表评论