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

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

问题描述

人们为 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 Hook 的常见类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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