很多程序员不爱写注释,特别是svn提交的时候,文件做了什么修改都没有一个简单的备注,往往都是直接提交,这样是非常不利于团队开发的。所以就有了svn提交的时候,强制修改文件的备注。

步骤如下:

1、先找到对应项目的svn版本库hooks

sudo find / -name hooks

2、假设进入test_wx项目下面的svn版本库

复制一份pre-commit.tmpl文件

  cp pre-commit.tmpl  pre-commit

修改pre-commit的权限

  chmod +x pre-commit

3、编辑pre-commit文件

  vim pre-commit

修改后代码如下

  

# If the hook program exits with success, the txn is committed; but
# if it exits with failure (non-zero), the txn is aborted, no commit
# takes place, and STDERR is returned to the client. The hook
# program can use the 'svnlook' utility to help it examine the txn.
#
# On a Unix system, the normal procedure is to have 'pre-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.
#
# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
#
# This is why we recommend using the read-only 'svnlook' utility.
# In the future, Subversion may enforce the rule that pre-commit
# hooks should not modify the versioned data in txns, or else come
# up with a mechanism to make it safe to do so (by informing the
# committing client of the changes). However, right now neither
# mechanism is implemented, so hook writers just have to be careful.
#
# Note that 'pre-commit' must be executable by the user(s) who will
# invoke it (typically the user httpd runs as), and that user must
# have filesystem-level permission to access the repository.
#
# On a Windows system, you should name the hook program
# 'pre-commit.bat' or 'pre-commit.exe',
# but the basic idea is the same.
#
# The hook program typically does not inherit the environment of
# its parent process. For example, a common problem is for the
# PATH environment variable to not be set to its usual value, so
# that subprograms fail to launch unless invoked via absolute path.
# If you're having unexpected problems with a hook program, the
# culprit may be unusual (or missing) environment variables.
#
# Here is an example hook script, for a Unix /bin/sh interpreter.
# For more examples and pre-written hooks, see those in
# the Subversion repository at
# http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ and
# http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/ 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 ];
then
echo -e "注释信息不能为空且不少于5个字!" >&
exit
fi
exit

4、无需重启svn服务,直接测试。效果如下

参考文章:http://www.linuxyan.com/linux-service/229.html

linux svn 提交文件时强制填写备注的更多相关文章

  1. svn 中commit时必须填写备注信息如何设置

    在软件开发团队中总是有人忘记添加备注信息,可以通过下面方式进行设置,从而在commit时强制需要填写备注信息. 在服务端选中需要设置的项目进行设置. 选中项目右键,"所以任务"-& ...

  2. SVN 提交代码时强制加入注释内容

    参考: 关于SVN提交强制加入注释 方式一是使用的服务器脚本,对所有SVN用户生效. 方式二是使用本地钩子,仅对当前SVN用户生效.

  3. SVN配置钩子文件限制提交文件时必须填写更新日志

    进入相应SVN仓库hooks目录,编辑文件pre-commit #!/bin/sh REPOS="$1"TXN="$2" SVNLOOK=/usr/bin/sv ...

  4. SVN设置钩子文件限制提交文件时必须填写更新日志

    进入相应SVN仓库hooks目录,编辑文件pre-commit #!/bin/sh # PRE-COMMIT HOOK## The pre-commit hook is invoked before ...

  5. Visual studio 创建文件时自动添加备注

    Visual studio 创建文件时自动添加备注 描述 要求每回添加一个类,普通类或单元测试类文件头自动添加备注, 比如:Copyright, FileName, Author and so on. ...

  6. Linux下svn提交文件后自动同步更新到网站目录

    有时,对于多文件需要上传到服务器的时候将会很麻烦,但是如果使用svn的钩子脚本就容易实现本地提交svn后,自动同步代码文件到远程服务器的网站目录下,而不必手动上传了. 首先,在网站目录下checkou ...

  7. SVN提交修改时出现:Checksum mismatch

    在使用SVN commit提交修改时,提示Checksum mismatch 问题,提示版本不一致,不能提交,类似于下图. 图片来源于网络,如有侵权,请告知删除. 搜索stackoverflow.co ...

  8. SVN提交文件失败:系统找不到指定路径

    完成程序代码工作后,进行SVN的文件提交.先进行项目的更新,然后在修改的文件上进行提交操作,发现SVN弹出提示信息,“系统找不到指定路径”提交失败,如下图:                       ...

  9. SVN 提交代码时提示文件已经存在解决办法

    在SVN里面找到这个文件,把这个文件右键delete删除掉,然后提交一下commit ,然后在项目中也把这个文件删除了,然后再添加到项目中提交,commit一下,就好了,解决

随机推荐

  1. Zookeeper概论(对zookeeper的概论、原理、架构等的理解)

    Zookeeper概论(对zookeeper的概论.原理.架构等的理解) 一.概论 Zookeeper是一个分布式的.开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是h ...

  2. TableView分割线从顶端开始

    如果什么都不设置的话 分割线是从cell.textlabel处开始的 如果加上 [_myTableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0) ...

  3. ST第二次作业,相关程序测试及测试用例

    public static int findLast(int[]x,int y){ for(int i = x.length-1;i>0;i--){//i>=0 if(x[i] == y) ...

  4. android 获取包信息

    private static int testPackageInfo(Context context){ int localVersionCode = 9999; try { PackageInfo ...

  5. Git 基础

    取得项目的 Git 仓库 有两种取得 Git 项目仓库的方法.第一种是在现存的目录下,通过导入所有文件来创建新的 Git 仓库.第二种是从已有的 Git 仓库克隆出一个新的镜像仓库来. 在工作目录中初 ...

  6. JavaScript中reduce()方法

    原文  http://aotu.io/notes/2016/04/15/2016-04-14-js-reduce/   JavaScript中reduce()方法不完全指南 reduce() 方法接收 ...

  7. Qt实用小技巧(转)

    原博网址:http://www.cnblogs.com/feiyangqingyun/archive/2010/12/06/1898143.html 1.如果在窗体关闭前自行判断是否可关闭答:重新实现 ...

  8. 【Unity3D基础教程】给初学者看的Unity教程(四):通过制作Flappy Bird了解Native 2D中的RigidBody2D和Collider2D

    作者:王选易,出处:http://www.cnblogs.com/neverdie/ 欢迎转载,也请保留这段声明.如果你喜欢这篇文章,请点[推荐].谢谢! 引子 在第一篇文章[Unity3D基础教程] ...

  9. 压力测试报出503错误---ASP.NET支持大并发的相关配置

    项目反馈报出503错误,需要收集性能数据如下: 1.Windows性能监视器,该应用程序池进程的线程和处理队列 2.问题重现时的进程dump 这是请求到达IIS后遇到的第一个队列,HTTP.sys收到 ...

  10. ping脚本

    #!/bin/bash for x in{100..200} ####区间为192.168.100.100-192.168.100.200 do x=$(($x-100)) if fping -c 1 ...