Windows预提交钩子,用于注释长度的Subversion [英] Windows Pre-commit hook for comment length Subversion

查看:65
本文介绍了Windows预提交钩子,用于注释长度的Subversion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎对此一无所获.可以在网上搜索脚本,等等.任何人都可以找到一个脚本,您可以在Windows环境中编辑开箱即用的pre-commit.tmpl,该环境要求输入x字符以对Tortoise Subversion中的提交发表评论.全球范围内,因此团队中的所有成员都是必需的,而此要求是从SVN服务器下推到客户端的?

I seem to be getting nowhere with this. Either searching the web for a script, etc. Anyone got a script that you can just edit the out-of-box pre-commit.tmpl in a Windows environment that requires x chars to be entered in for a comment on commit in Tortoise Subversion globally so that all members on the team are required whereas this requirement is pushed down to the clients from SVN server?

我不知道脚本语言,这应该是非常简单的事情,如果我不花时间在接下来的3个小时内弄清楚脚本的话.

I don't know the scripting language and this should be something pretty damn simple without me taking the time to figure out scripting for the next 3 hours.

推荐答案

这是一个.bat文件,要求有注释.它会检查评论中是否存在至少一个字符.

This is a .bat file to require there is a comment. It checks for the existence of at least one character in the comment.

 @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           

 svnlook log %REPOS% -t %TXN% | findstr . > nul  
 if %errorlevel% gtr 0 (goto err) else exit 0  

 :err  
 echo. 1>&2  
 echo Your commit has been blocked because you didn't enter a comment. 1>&2  
 echo Write a log message describing the changes made and try again. 1>&2
 echo Thanks 1>&2
 exit 1

此文件位于存储库的/hooks文件夹中,名为pre-commit.bat.如果您需要最少的字符,则要修改的行是

This file sits in the /hooks folder of the repository, named pre-commit.bat. If you need a minimum amount of characters, the line to modify is

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

因此,如果您至少需要10个字符,则需要10个字符,而不仅仅是一个.

So if you wanted a minimum of 10 characters, you need to have 10 .'s rather than just one

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

更多 findstr的高级选项命令可以使您做得更好检查(某些字符集等)

More advanced options for the findstr command will let you do fancier checks (certain character sets, ect)

这篇关于Windows预提交钩子,用于注释长度的Subversion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆