Subversion Hook 的常见类型

发布于 2024-07-05 01:45:06 字数 51 浏览 6 评论 0原文

人们在 Subversion 中使用什么类型的钩子脚本? 只是一般想法,但代码也很棒!

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

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

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

发布评论

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

评论(16

纵性 2024-07-12 01:45:06

我认为最常见的一种是允许人们在提交后更改修订意见。

您需要启用“pre-revprop-change”挂钩脚本才能实现此目的。 提供的示例(如果启用)仅允许编辑注释属性,并且只能是原始提交者。 非常适合纠正拼写错误。

The most common one I think is to allow people to change revision comments after comitting.

You need to enable the 'pre-revprop-change' hook script to allow that. The example provided, if enabled allows editing only the comment property and only be the original comitter. Great for correcting typos.

甜点 2024-07-12 01:45:06

用于通知错误/问题管理系统存储库更改的挂钩。 IE。 提交消息中包含 issues:546 或类似标签,该标签被解析并馈送到错误管理系统。

A hook to notify the bug/issue management system of changes to repository. Ie. the commit message has issue:546 or similar tag in it that is parsed and fed to the bug management system.

凝望流年 2024-07-12 01:45:06

我们使用钩子脚本检查以下内容:

  • 是否已提供提交日志消息
  • 是否已为提交指定了审阅者
  • 存储库中没有自动生成的代码或禁止的文件类型 在
  • 分支/标签被修改时发送电子邮件创建

我们仍然希望实现以下内容:

  • 当用户获取文件锁时发送电子邮件
  • 当您的锁被盗时发送电子邮件
  • 当修订属性更改时向所有人发送电子邮件

We check the following with our hook scripts:

  • That a commit log message has been supplied
  • That a reviewer has been specified for the commit
  • That no automatically generated code or banned file types land up in the repository
  • Send an email out when a branch / tag is created

We still want to implement the following:

  • Send an email when a user acquires a lock on a file
  • Send an email when your lock has been stolen
  • Send an email to everyone when a revision property has been changed
我不吻晚风 2024-07-12 01:45:06

我们使用提交挂钩脚本来触发我们的发布机器人。 在我们的不同产品中将新版本信息写入名为changes.txt的文件将触发标签和相关工件的创建。

We use a commit hook script to trigger our release robot. Writing new release information to a file named changes.txt in our different products will trigger the creation of a tag and the relevant artifacts.

一身仙ぐ女味 2024-07-12 01:45:06

我有一个使用 Ruby Tinder 库的设置,我将其发送到篝火室,如果有人想要该脚本,我可以将代码发布或发送给您。

我见过的其他常见内容是错误跟踪系统和电子邮件通知的帖子。

I have one setup using the Ruby Tinder library that I send to a campfire room, if anyone wants the script I can post or send the code to you.

Other common ones I've seen are posts to bug tracking systems and email notifications.

最初的梦 2024-07-12 01:45:06

Windows 预提交挂钩来检查日志是否包含某些内容。

@ECHO OFF
setlocal

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Get subversion arguments
set repos=%~1
set txn=%2

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set some variables
set svnlookparam="%repos%" -t %txn%

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Make sure that the new svn:log message contains some text.
set bIsEmpty=true
for /f "tokens=* usebackq" %%g in (`svnlook log %svnlookparam%`) do (
   set bIsEmpty=false
)
if '%bIsEmpty%'=='true' goto ERROR_EMPTY

echo Allowed. >&2

goto :END


:ERROR_EMPTY
echo Empty log messages are not allowed. >&2
goto ERROR_EXIT

:ERROR_EXIT
:: You may require to remove the /b below if your hook is called directly by subversion
exit /b 1

:END
endlocal

Windows pre-commit hook to check that log contains something.

@ECHO OFF
setlocal

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Get subversion arguments
set repos=%~1
set txn=%2

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set some variables
set svnlookparam="%repos%" -t %txn%

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Make sure that the new svn:log message contains some text.
set bIsEmpty=true
for /f "tokens=* usebackq" %%g in (`svnlook log %svnlookparam%`) do (
   set bIsEmpty=false
)
if '%bIsEmpty%'=='true' goto ERROR_EMPTY

echo Allowed. >&2

goto :END


:ERROR_EMPTY
echo Empty log messages are not allowed. >&2
goto ERROR_EXIT

:ERROR_EXIT
:: You may require to remove the /b below if your hook is called directly by subversion
exit /b 1

:END
endlocal
尐偏执 2024-07-12 01:45:06

我在提交时忘记输入评论。 没有时间弄清楚为什么我的 pre-revprop-change 挂钩不起作用。 因此,以下 svnadmin 命令可以帮助我输入提交消息:
svnadmin setlog <我的存储库的文件系统路径> --bypass-hooks -r 117 垃圾,
其中“垃圾”是包含我想要作为评论的文本的文件。 svn setlog help 有更多使用信息...

I forgot to enter a comment while committing. Didn't have time to figure out why my pre-revprop-change hook wasn't working. So the following svnadmin command worked for me to enter a commit message:
svnadmin setlog <filesystem path to my repository> --bypass-hooks -r 117 junk,
where "junk" is the file containing the text which I wanted to be the comment. svn setlog help has more usage info...

少女七分熟 2024-07-12 01:45:06

不久前,颠覆用户邮件列表对此进行了讨论。 这篇文章特别提出了一些有用的想法。

This was discussed on the subversion users mailing list a while ago. This post in particular has some useful ideas.

怪我闹别瞎闹 2024-07-12 01:45:06

提交后挂钩,用于将存储库中发生更改的电子邮件通知发送到电子邮件列表。 您需要将 sendmail.exe 与 sendmail.ini 放在与挂钩文件相同的文件夹中。

您还需要 post-commit.cmd 旁边的文件 post-commit.tos.txt 来列出邮件收件人。 该文件应包含:

[email protected],[email protected],[email protected]

这是挂钩代码:

@ECHO OFF
setlocal

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Get subversion arguments
set repos=%~1
set rev=%2

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set some variables
set tos=%repos%\hooks\%~n0.tos.txt
set reposname=%~nx1
set svnlookparam="%repos%" --revision %rev%

if not exist "%tos%" goto :END

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Prepare sendmail email file
set author=
for /f "tokens=* usebackq" %%g in (`svnlook author %svnlookparam%`) do (
  set author=%%g
)

for /f "tokens=* usebackq delims=" %%g in ("%tos%") do (
  set EmailNotificationTo=%%g
)
set SendMailFile=%~n0_%reposname%_%rev%.sm

echo To: %EmailNotificationTo% >> "%SendMailFile%"
echo From: %reposname%[email protected] >> "%SendMailFile%"
echo Subject: [%reposname%] Revision %rev% - Subversion Commit Notification  >> "%SendMailFile%"

echo --- log [%author%] --- >> "%SendMailFile%"
svnlook log %svnlookparam% >> "%SendMailFile%" 2>&1
echo --- changed --- >> "%SendMailFile%"
svnlook changed %svnlookparam% --copy-info >> "%SendMailFile%" 2>&1

echo .>> "%SendMailFile%"

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Send email
type "%SendMailFile%" | "%~dp0sendmail.exe" -t

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Clean-up
if exist "%SendMailFile%" del "%SendMailFile%"


:END
endlocal

post-commit hook to send email notification that something changed in the repository to a list of emails. You need sendmail.exe in the same folder than your hook file, along with sendmail.ini.

You also need a file post-commit.tos.txt next to your post-commit.cmd to list the mail recipients. The file should contain:

[email protected],[email protected],[email protected]

Here is the hook code:

@ECHO OFF
setlocal

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Get subversion arguments
set repos=%~1
set rev=%2

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set some variables
set tos=%repos%\hooks\%~n0.tos.txt
set reposname=%~nx1
set svnlookparam="%repos%" --revision %rev%

if not exist "%tos%" goto :END

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Prepare sendmail email file
set author=
for /f "tokens=* usebackq" %%g in (`svnlook author %svnlookparam%`) do (
  set author=%%g
)

for /f "tokens=* usebackq delims=" %%g in ("%tos%") do (
  set EmailNotificationTo=%%g
)
set SendMailFile=%~n0_%reposname%_%rev%.sm

echo To: %EmailNotificationTo% >> "%SendMailFile%"
echo From: %reposname%[email protected] >> "%SendMailFile%"
echo Subject: [%reposname%] Revision %rev% - Subversion Commit Notification  >> "%SendMailFile%"

echo --- log [%author%] --- >> "%SendMailFile%"
svnlook log %svnlookparam% >> "%SendMailFile%" 2>&1
echo --- changed --- >> "%SendMailFile%"
svnlook changed %svnlookparam% --copy-info >> "%SendMailFile%" 2>&1

echo .>> "%SendMailFile%"

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Send email
type "%SendMailFile%" | "%~dp0sendmail.exe" -t

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Clean-up
if exist "%SendMailFile%" del "%SendMailFile%"


:END
endlocal
霊感 2024-07-12 01:45:06

我正在使用提交后挂钩(我认为就是这个< /a>) 为每次提交向 Basecamp 上的论坛发布消息。 优势:

  1. 作为首席开发人员,我每天早上都会收到一份提交汇总(通过来自 Basecamp 论坛的 RSS 提要),并且可以很快看到我的团队的最新进展。

  2. 我们的 Trac/SVN 安装位于防火墙后面,因此这为其他地点的上级提供了了解我们正在做的事情的窗口。 他们可能不理解,但对于经理来说,很多活动看起来像是,嗯,很多活动;)

我想这的最终结果与@Aviv 所做的类似。

我正在研究在单独的服务器上构建最新提交以进行持续集成的解决方案,但我必须改变我们对数据库模式进行更改的方式,然后才能起作用。

I'm using post-commit hooks (I think it's this one) to post a message to a forum on Basecamp for each commit. Two advantages:

  1. As the lead developer, I get a roll-up of commits every morning (via the RSS feed from that basecamp forum) and can see what my team has been up to pretty quickly.

  2. Our Trac/SVN install is behind our firewall, so this gives my higher-ups in other locations a window into what we're doing. They might not understand it, but to a manager a lot of activity looks like, well, a lot of activity ;)

I guess the end result of this is similar to what @Aviv is doing.

I'm looking into solutions for building the latest commit on a separate server for continuous integration, but I'm going to have to change the way we make changes to our database schema before that will work.

你好,陌生人 2024-07-12 01:45:06

对于那些正在寻找 pre-revprop-change.bat 进行 snvsync 操作的人:

https ://gist.github.com/1679659

@ECHO OFF

set user=%3

if /I '%user%'=='syncuser' goto ERROR_REV

exit 0

:ERROR_REV echo "Only the syncuser user may change revision properties" >&2
exit 1

它来自这里:http://chestofbooks.com/computers/revision-control/subversion-svn/Repository-Replication-Reposadmin-Maint-Replication.html 并已针对 Windows 进行了调整。

For those who are looking for a pre-revprop-change.bat for a snvsync operation :

https://gist.github.com/1679659

@ECHO OFF

set user=%3

if /I '%user%'=='syncuser' goto ERROR_REV

exit 0

:ERROR_REV echo "Only the syncuser user may change revision properties" >&2
exit 1

It just comes from here : http://chestofbooks.com/computers/revision-control/subversion-svn/Repository-Replication-Reposadmin-Maint-Replication.html and has been adapted for Windows.

亢潮 2024-07-12 01:45:06

我们使用它们的几件事:

several things we use them for:

  • integrating with the bug tracker (Trac in our case - a commit message that says 'Closes #514' automatically marks that bug as closed
  • integrating with the build integration (buildbot in our case - a commit to a watched branch triggers a build
  • pre-commit hook for validating the commit - we use svnchecker. It validates our Python code for PEP8 correctness
  • sending checkin mails to a mailing list
  • running indentation scripts
粉红×色少女 2024-07-12 01:45:06

在我的工作场所,我们设置了一个提交后挂钩,可以生成 RSS 提要,这些提要显示在各种仪表板中,供代码审阅者了解何时需要进行审阅,并让我们了解新员工是否做出了足够的承诺。

In my work place we've set up a post-commit hook that generates RSS feeds that are displayed in various dash boards and are used for code reviewers to know when it is time to review and for us to see that new employees are committing enough.

微暖i 2024-07-12 01:45:06

我们使用 FogBugz 进行错误跟踪,它提供了 subversion 提交脚本,允许您在其中包含案例编号您签入评论,然后将错误与修复该错误的签入相关联。 它确实需要设置一个 WebSVN 实例,以便您的存储库拥有基于 Web 的查看器。

We use FogBugz for bug tracking, it provides subversion commit scripts that allow you to include a case number in your check in comments and then associates the bug with the check in that fixed it. It does require a WebSVN instance to be set up so that you have a web based viewer for your repository.

向日葵 2024-07-12 01:45:06

如果您有 UNIX 和 Windows 用户混合使用存储库,我强烈建议您使用 case-insensitive.py 预提交挂钩脚本作为预防措施。 它可以防止由于 Windows 用户的 svn 更新失败的难以解决的情况文件重命名仅更改文件名的大小写。 相信我,它很有可能会帮你省去麻烦。

If you have a mix of unix and Windows users working with the repository, I urge you to use the case-insensitive.py pre-commit hook-script as a precautionary measure. It prevents hard-to-sort-out situations where svn updates fail for Windows users because of a file rename which only changed the case of the file name. Believe me, there is a good chance it will save you trouble.

送舟行 2024-07-12 01:45:06

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

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

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

另一件事是,我收到了其他用户关于使用 /bexit 命令的问题的报告。 如果错误情况表现不佳,您可能只需要在特定应用程序中删除该 /b 即可。

@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 

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.

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.

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.

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 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文