VisualSVN 预提交规则

发布于 2024-09-03 00:32:18 字数 765 浏览 9 评论 0原文

将此挂钩与 VisualSVN Server 结合使用,作为 pre-commit.bat 添加到 Repository/hooks 文件夹中。

我的问题是如何添加注释必须始终以数值开头的规则?我希望评论的第一部分始终是错误跟踪器的问题号。例如。 “123 - 此提交修复了问题 123”

@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 Your commit has been blocked because you didn't give any log message 1>&2
echo Please write a log message describing the purpose of your changes and 1>&2
echo then try committing again. -- Thank you 1>&2
exit 1

Using this hook with VisualSVN Server, added to the Repository/hooks folder as pre-commit.bat.

My question is how do I add the rule that a comment must always start with a numeric value? I want the first part of the comment to always be the issue number from a bug tracker. Eg. "123 - this commit fixes issue 123"

@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 Your commit has been blocked because you didn't give any log message 1>&2
echo Please write a log message describing the purpose of your changes and 1>&2
echo then try committing again. -- Thank you 1>&2
exit 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天涯沦落人 2024-09-10 00:32:18

尝试以下正则表达式:

findstr "^[0-9]"

Ie

svnlook log %REPOS% -t %TXN% | findstr "^[0-9] > nul
if %errorlevel% gtr 0 (goto err) else exit 0

Try following regular expression:

findstr "^[0-9]"

I.e.

svnlook log %REPOS% -t %TXN% | findstr "^[0-9] > nul
if %errorlevel% gtr 0 (goto err) else exit 0
┼── 2024-09-10 00:32:18

请参阅文章 KB140:验证 VisualSVN 服务器中的提交日志消息 并使用选项 <代码>--regexp ARG。如果您希望提交日志消息始终以数值开头,请尝试使用 \d+ 正则表达式值。

例如,像这样:

"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks" check-logmessage ^
  --regexp "\d+" ^
  -t "%2" "%1"
IF ERRORLEVEL 1 echo Issue number must be specified. >&2 & exit /b 1

See the article KB140: Validating commit log messages in VisualSVN Server and use the option --regexp ARG. In your case when you want the commit log message to always start with a numeric value, try the \d+ regexp value.

E.g., like this:

"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks" check-logmessage ^
  --regexp "\d+" ^
  -t "%2" "%1"
IF ERRORLEVEL 1 echo Issue number must be specified. >&2 & exit /b 1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文