强制用户写日志

Posted on Posted in 8.附录

强制用户写日志

有两种方法可以防止用户在不写日志的情况下进行提交操作。一种方式只对TortoiseSVN有效,另外一种方法对任何Subversion的客户端都有效,但是需要直接访问服务器。

服务器端的钩子脚本(Hook-script)

如果能够直接访问服务器,可以安装一个pre-commit钩子脚本,通过这个脚本可以阻止所有空白日志或者日志太简短的提交操作。

In the repository folder on the server, there's a sub-folder hooks which contains some example hook scripts you can use. The file pre-commit.tmpl
 contains a sample script which will reject commits if no log message
is  supplied, or the message is too short. The file also contains
comments  on how to install/use this script. Just follow the
instructions in that  file.

除了TortoiseSVN,如果还要同时使用其他的Subversion客户端,推荐使用这种方法。缺点是提交是被服务器端拒绝的,因此用户会看到一个错误消息。客户端无法在提交之前就知道会被拒绝。如果希望在日志的内容达到足够长之前,TortoiseSVN
的 OK 按钮处于无效的状态,请使用下面的方法。

工程(Project)属性

TortoiseSVN 使用属性来控制它的一些特性。这其中有一个 tsvn:logminsize 属性。

如果给一个文件夹设置了这个属性,在提交对话框里的日志信息达到属性里定义的长度之前,提交对话框的 OK 按钮会处于无效状态。

关于工程属性的具体信息,请参照 “项目设置”一节