Subversion Hook 的常见类型
人们在 Subversion 中使用什么类型的钩子脚本? 只是一般想法,但代码也很棒!
What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
我认为最常见的一种是允许人们在提交后更改修订意见。
您需要启用“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.
用于通知错误/问题管理系统存储库更改的挂钩。 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.
我们使用钩子脚本检查以下内容:
我们仍然希望实现以下内容:
We check the following with our hook scripts:
We still want to implement the following:
我们使用提交挂钩脚本来触发我们的发布机器人。 在我们的不同产品中将新版本信息写入名为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.
我有一个使用 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.
Windows 预提交挂钩来检查日志是否包含某些内容。
Windows pre-commit hook to check that log contains something.
我在提交时忘记输入评论。 没有时间弄清楚为什么我的 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...不久前,颠覆用户邮件列表对此进行了讨论。 这篇文章特别提出了一些有用的想法。
This was discussed on the subversion users mailing list a while ago. This post in particular has some useful ideas.
提交后挂钩,用于将存储库中发生更改的电子邮件通知发送到电子邮件列表。 您需要将 sendmail.exe 与 sendmail.ini 放在与挂钩文件相同的文件夹中。
您还需要 post-commit.cmd 旁边的文件 post-commit.tos.txt 来列出邮件收件人。 该文件应包含:
这是挂钩代码:
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:
Here is the hook code:
我正在使用提交后挂钩(我认为就是这个< /a>) 为每次提交向 Basecamp 上的论坛发布消息。 优势:
作为首席开发人员,我每天早上都会收到一份提交汇总(通过来自 Basecamp 论坛的 RSS 提要),并且可以很快看到我的团队的最新进展。
我们的 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:
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.
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.
对于那些正在寻找 pre-revprop-change.bat 进行 snvsync 操作的人:
https ://gist.github.com/1679659
它来自这里: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
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.
我们使用它们的几件事:
several things we use them for:
在我的工作场所,我们设置了一个提交后挂钩,可以生成 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.
我们使用 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.
如果您有 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.
我正在使用
pre-revprop-change
挂钩,它允许我在执行提交后实际返回并编辑注释和此类信息。 如果提交注释中缺少/错误信息,这非常有用。在这里,我发布了一个适用于 Windows NT 或更高版本的
pre-revprop-change.bat
批处理文件。 你当然可以通过更多修改来增强它。 您还可以导出一个
post-revprop-change.cmd
从它备份旧的snv:log
某处或只是将其附加到新日志中。唯一棘手的部分是能够实际解析标准输入
批处理文件。 这是通过 FIND.EXE 命令完成的。
另一件事是,我收到了其他用户关于使用
/b
和exit
命令的问题的报告。 如果错误情况表现不佳,您可能只需要在特定应用程序中删除该/b
即可。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. Youcan certainly enhance it with more modifications. You can also derive a
post-revprop-change.cmd
from it to back up the oldsnv: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 theexit
command. You may just need to remove that/b
in your specific application if error cases do not behave well.