svn 预提交挂钩禁止在非根目录上使用 svn:mergeinfo
我想使用预提交挂钩来防止开发人员在非根目录上设置 svn:mergeinfo 。也就是说,我想强制 svn:mergeinfo 只能在“trunk”或“branches/branchName”等目录上设置。有时需要“提醒”开发人员,使用根目录的子目录作为合并目标并不是一个好的做法(根据列出的最佳实践此处)。有谁有这样的钩子脚本或者知道我在哪里可以找到一个?我在 Windows 环境中,所以批处理或 powershell 会更好,但任何东西肯定会有帮助。
I would like to use a pre-commit hook that prevents developers from setting svn:mergeinfo on non-root directories. That is, I want to enforce that svn:mergeinfo can only be set on directories like "trunk" or "branches/branchName". Developers sometimes need to be "reminded" that it's not good practice to use a subdirectory of the root as a merge target (per the best practices listed here). Does anyone have such a hook script or know where I could find one? I am in a windows environment, so batch or powershell would be preferable, but anything would certainly be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,我建议使用 perl 或 python 来完成任务,Windows 批处理还有很多不足之处。
您可以使用 http://svn.apache 中的一些示例脚本.org/repos/asf/subversion/trunk/tools/hook-scripts/ 开始。例如,verify-po.py 脚本检查文件编码,commit-access-control.pl.in 检查作者是否具有提交权限。您可能会在脚本中使用 svnlook diff (如后一个)来获取目录的更改属性,并使用正则表达式遍历相应的路径,无论它们是分支还是标记。
更新
找到 enforcer 预提交挂钩脚本 这似乎就是您正在寻找的内容。
它包含多个方法,其中包括 verify_property_line_added(),因为它会为添加到文件属性的每一行调用。
First of all, I'd recommend using perl or python to do the task, windows batch leaves much to be desired.
You can use some example script from http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ to start from. For example, verify-po.py script checks file encodings and commit-access-control.pl.in checks whether author has permissions to commit. You'd probably employ svnlook diff in your script (as in the latter one) to get changed properties for directories and go through the corresponding paths whether they're branches or tags using regular expression.
Update
Found enforcer pre-commit hook script which seems to be what you're looking for.
It contains several methods and verify_property_line_added() among them, since it's called for each line that is added to a property on a file.
如果您可以在服务器上进行 CPAN:
https://github .com/gnustavo/SVN-Hooks/blob/master/examples/check-mergeinfo.pl
如果没有(基于 http://comments.gmane.org/gmane.comp.version-control.subversion.user/118969):
If you can CPAN on the server:
https://github.com/gnustavo/SVN-Hooks/blob/master/examples/check-mergeinfo.pl
If not (based on http://comments.gmane.org/gmane.comp.version-control.subversion.user/118969):