我想在存储库浏览器中编辑日志注释,并收到一条错误消息,指出存储库中不存在pre-revprop-change挂钩.除了有一个可怕的名字,什么是pre-revprop-change钩子,我该如何创建它?
对于Windows,这里是一个示例批处理文件的链接,该文件仅允许更改日志消息(而不是其他属性):
http://ayria.livejournal.com/33438.html
基本上将下面的代码复制到文本文件中并将其命名并将其pre-revprop-change.bat
保存在\hooks
存储库的子目录中.
@ECHO OFF :: Set all parameters. Even though most are not used, in case you want to add :: changes that allow, for example, editing of the author or addition of log messages. set repository=%1 set revision=%2 set userName=%3 set propertyName=%4 set action=%5 :: Only allow the log message to be changed, but not author, etc. if /I not "%propertyName%" == "svn:log" goto ERROR_PROPNAME :: Only allow modification of a log message, not addition or deletion. if /I not "%action%" == "M" goto ERROR_ACTION :: Make sure that the new svn:log message is not empty. set bIsEmpty=true for /f "tokens=*" %%g in ('find /V ""') do ( set bIsEmpty=false ) if "%bIsEmpty%" == "true" goto ERROR_EMPTY goto :eof :ERROR_EMPTY echo Empty svn:log messages are not allowed. >&2 goto ERROR_EXIT :ERROR_PROPNAME echo Only changes to svn:log messages are allowed. >&2 goto ERROR_EXIT :ERROR_ACTION echo Only modifications to svn:log revision properties are allowed. >&2 goto ERROR_EXIT :ERROR_EXIT exit /b 1
基本上它是在存储库中修改unversioned属性之前启动的脚本,这样您就可以更精确地管理存储库中发生的事情.
SVN distrib中有不同钩子的模板,位于/ hooks子目录中(*.tmpl,你必须编辑和重命名,具体取决于你的操作系统,才能激活).
对于Linux允许编辑日志注释,
将文件pre-revprop-change.tmpl
放在hooks
存储库的目录中
将文件复制到同一目录,将其重命名为 pre-revprop-change
赋予文件执行权限(例如,对于服务器用户www-data
)
编辑:(感谢lindes)
之后,您可能必须编辑脚本以返回0
要允许的编辑类型的退出值.
这里是堆栈溢出问题的链接,其中包含许多常见的钩子Subversion Hooks的常见类型,包括pre-revprop-change
这里交叉发布的Windows钩子的原始来源.
你应该参考那里,因为他们可能会随着时间的推
谢谢#patmortech
我添加了"只有同一个用户才能更改代码"的代码.
:: Only allow editing of the same user. for /f "tokens=*" %%a in ( '"%VISUALSVN_SERVER%\bin\svnlook.exe" author -r %revision% %repository%') do ( set orgAuthor=%%a ) if /I not "%userName%" == "%orgAuthor%" goto ERROR_SAME_USER