常见的Subversion挂钩类型 [英] Common Types of Subversion Hooks

查看:108
本文介绍了常见的Subversion挂钩类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们用于Subversion的挂钩脚本有哪些?只是一般的想法,但是代码也很棒!

What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!

推荐答案

我正在使用pre-revprop-change挂钩,该挂钩允许我在执行提交后实际返回并编辑注释和此类信息.如果提交注释中缺少/错误的信息,这将非常有用.

I am using the pre-revprop-change hook that allows me to actually go back and edit comments and such information after the commit has been performed. This is very useful if there is missing/erroneous information in the commit comments.

在这里,我发布Windows NT或更高版本的pre-revprop-change.bat批处理文件.你 当然可以通过更多修改来增强它.您还可以派生一个 post-revprop-change.cmd从它备份旧的snv:log到某个地方,或者只是将其附加到新日志中.

Here I post a pre-revprop-change.bat batch file for Windows NT or later. You can certainly enhance it with more modifications. You can also derive a post-revprop-change.cmd from it to back up the old snv:log somewhere or just to append it to the new log.

唯一棘手的部分是能够实际解析标准输入 批处理文件.这是通过FIND.EXE命令完成的.

The only tricky part was to be able to actually parse the stdin from the batch file. This is done here with the FIND.EXE command.

另一件事是,我已经从其他用户那里收到有关使用/bexit命令的问题的报告.如果错误情况不能很好地解决,您可能只需要在特定的应用程序中删除该/b.

The other thing is that I have had reports from other users of issues with the use of the /b with the exit command. You may just need to remove that /b in your specific application if error cases do not behave well.

@ECHO OFF

set repos=%1
set rev=%2
set user=%3
set propname=%4
set action=%5

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Only allow changes to svn:log. The author, date and other revision
:: properties cannot be changed
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if /I not '%propname%'=='svn:log' goto ERROR_PROPNAME

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Only allow modifications to svn:log (no addition/overwrite or deletion)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if /I not '%action%'=='M' goto ERROR_ACTION

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Make sure that the new svn:log message contains some text.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
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 properties are not allowed. >&2
goto ERROR_EXIT

:ERROR_PROPNAME
echo Only changes to svn:log revision properties 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 

这篇关于常见的Subversion挂钩类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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