VisualSVN Server提交前检查备注信息

  • 检查代码的时候,如果发现SVN提交上来的代码没有任何SVN备注,那是一件很痛苦的事情,这次提交到底是为了什么?可能还需要我们一行一行代码去查看。

  • 所以很多时候,我们希望程序员提交SVN前必须保证备注的完整。

  • 在VisualSVN Server里,要实现这个功能很简单,在主界面里右键当前项目 “所有任务”》“Manage Hooks” 》选中Pre-commit hook然后edit编辑,添加如下代码

@echo off
::    
:: Stops commits that have empty log messages.
::

@echo off

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check for an empty log message
svnlook log %REPOS% -t %TXN% | findstr . > nul
if %errorlevel% gtr 0 (goto err) else exit 0

:err
echo. 1>&2
echo 信息(备注)不允许为空,请填写信息然后重试 1>&2
exit 1

  • 限制字数
@echo off
::    
:: Stops commits that have empty log messages.
::

@echo off

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check that logmessage contains at least 16 characters
svnlook log %REPOS% -t %TXN% | findstr ................ > nul
if %errorlevel% gtr 0 (goto err) else exit 0

:err
echo. 1>&2
echo Note must be added when submitting the file, which cannot be less than 16 characters (8 Chinese characters), and the submission is terminated. 1>&2
exit 1

  • 保存后,即刻生效。
    ————————————————
    版权声明:本文为CSDN博主「星海设计」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/FormatRain/article/details/117227783
posted @ 2022-11-11 20:47  小匠i  阅读(50)  评论(0编辑  收藏  举报