要么孵化 要么臭掉
svn pre-commit hook 的加载
SVN 服务如果是配合 apache 通过 http/https 提供的话,可以通过配置AuthzSVNAccessFile文件来控制每一个项目目录的访问权限;但如果是通过内置的 svnserve 提供服务的话,就必须自己编写权限控制脚本作为 pre-commit hook 挂到版本库下面才能做到针对子目录和文件的访问权限控制。另一个最常在 pre-commit hook 中实现的功能是检查提交信息是否为空,可以养成自己每次提交都写说明信息的好习惯。
pre-commit hook 的脚本可以是 shell, perl, python, exe 等多种格式,相应的功能实现在网上也能很容易搜到。比如一个简单的防止提交说明信息为空的 shell 脚本:
#!/bin/sh
REPOS="$1"
TXN="$2"
RES="OK"
# Make sure that the log message contains some text.
SVNLOOK=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" 1>&2
exit 1
fi
# All checks passed, so allow the commit.
exit 0
把写好的脚本文件放置到相应的版本库目录下的 hooks 文件夹中即可(在 hooks 目录下也已经有各种 hook 脚本的模板供参考)。
- echo 错误提示信息的时候必须重定向到 stderr ,即 1>&2
- pre-commit 文件拷贝到 hooks 目录之后,需要 chmod 0755 pre-commit ,给 pre-commit 文件增加可执行权限(或者至少把文件owner改为 svn 服务运行用户并加上owner的x权限)
没做这两步的话,当你在客户端提交空信息的时候,相应的错误提示信息并不会被输出反馈到客户端上。
2008年 04月
2008年 03月
2008年 02月
2008年 01月
2007年 12月
2007年 11月
2007年 10月
2007年 09月
2007年 08月
2007年 07月
2007年 06月
2007年 05月
2007年 04月
2007年 03月
2007年 02月
2007年 01月
2006年 12月
2006年 11月
2006年 10月
2006年 09月
2006年 08月
2006年 07月
2006年 06月
2006年 05月
2006年 04月
2006年 03月
2006年 02月
2006年 01月
2005年 12月
2005年 11月
2005年 10月
2005年 09月
2005年 08月
2005年 07月
2005年 06月
2005年 05月
2005年 04月
Pivot1.24.1 开发