svn使用记录

1、如何在更新svn代码的时候同时更新和svn同一台机的web程序。

解决:在仓库目录hooks下建立一个文件post-commit增加以下内容

#!/bin/sh
export.UTF-8
svn update --username xx --password xxxx /home/www/xx

在使用这个代码之前,需要在路径/home/www/xx先把这个库拉下来,以后每次更新代码到svn的时候,会同时执行这段hooks代码。这样就可以同时更新web中的代码了。

2、如何在提交更新的时候强制写日志

解决:在hooks目录下执行下面的命令

cp pre-commit-tmpl pre-commit
chmod +x pre-commit

然后修改pre-commit文件

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 10 ];
then
    echo '日志啊!亲!' 1>&2
    exit 1
fi
 
# 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



你可能感兴趣的:(svn使用记录)