linux svn log限制,svn限制必须填写log message才能提交更新

20150325 by xiao 测试可以的pre-commit.bat放在hooks下面

@echo off

setlocal

set REPOS=%1

set TXN=%2

rem 保证输入8个字符

svnlook log %REPOS% -t %TXN% | findstr "........" > nul

if %errorlevel% gtr 0 goto :err_action

rem 过滤空格字符

svnlook log %REPOS% -t %TXN% | findstr /ic:"        " > nul

if %errorlevel% gtr 0 goto :success

:err_action

echo 你本次版本提交未填写任何变更的日志说明信息.      >&2

echo 请补充日志说明信息后再提交代码,例如:功能说明等.  >&2

echo 输入的日志信息不少于8个字符说明(或4个汉字),谢谢! >&2

echo *******************禁止空格数据***************** >&2

goto :err_exit

:err_exit

exit 1

:success

exit 0

英文:

@echo off

setlocal

set REPOS=%1

set TXN=%2

rem Ensure that the 8 characters

svnlook log %REPOS% -t %TXN% | findstr "........" > nul

if %errorlevel% gtr 0 goto :err_action

rem Filter space characters

svnlook log %REPOS% -t %TXN% | findstr /ic:"        " > nul

if %errorlevel% gtr 0 goto :success

:err_action

echo You have this version submitted is not complete any change log information>&2

echo Please add log information, and then submit your code, for example: Description of the function, and so on.>&2

echo Enter the log information less than 8 characters (or 4 characters), Thank you!>&2

echo ********The space data for prohibit**** >&2

goto :err_exit

:err_exit

exit 1

:success

exit 0

Linux未进行验证

利用svn的pre-commit钩子可简单实现此要求。进入仓库project1/hooks目录,找到pre-commit.tmpl文件,重命名,去掉后缀.tmpl。编辑pre-commit文件:(Linux系统和windows系统脚本内容见1和2)1、Linux系统

方法1:

将:$SVNLOOK log -t "$TXN" "$REPOS" | \grep "[a-zA-Z0-9]" > /dev/null || exit 1commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1这三行注释掉(前面加#符号),在此位置添加如下几行:LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`if [ "$LOGMSG" -lt 5 ];#要求注释不能少于5个字符,您可自定义thenecho -e "\nLog message cann't be empty! you must input more than 5 chars as comment!." 1>&2exit 1fi保存,退出。给pre-commit添加可执行权限:chmod +x pre-commit这里记得修改 $SVNLOOK=(svnlook的路径,/csvn的安装目录/bin/svnlook)配置结束,可以使用了。

方法2:

这两天把项目的开发机迁移到了linux环境,用python重写了原来的svn hook,保存为pre-commit放到svn的hooks目录下,chmod +x pre-commit加上执行权限即可。windows下写SVN钩子比较麻烦,只能是批处理或者exe,linux下随便用什么脚本语言写都可以,只要加上可执行权限就行了。

#! /usr/bin/env python# -*- coding: utf-8 -*- """SVN提交前检查钩子功能:        1、强制填写提交注释,内容10字节以上        2、强制注释格式为:xxx:xxx        3、提交文件检查,过滤不允许提交的文件 作者: 李思杰 <2012/04/28>""" import sysimport osimport re def main(argv):        (repos, txn) = argv        badlist = (".*config\.php$", ".*/php/cache", ".*test", "config\.js$","^.*\.db$")        message = "".join(os.popen("/usr/bin/svnlook log '%s' -t '%s'" % (repos, txn)).readlines()).strip()        if len(message)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值