在预提交中确定事务的基础修订版
我正在编写一个预提交挂钩,我想在事务之前根据文件的内容强制执行一些规则。因此,当事务开始时,我想 svnlook cat 标记为“U”、“UU”或“D”的任何文件的内容,没有未决的更改。我可以安全地获取提供的事务标识符(预提交的第二个参数)并去掉破折号及其后面的任何字符并认为是“基本修订版”吗?有没有更好的方法来获取这些信息?
I am writing a pre-commit hook where I would like to enforce some rule based on the content of a file before the transaction. Therefore, when a transaction begins, I would like to svnlook cat the contents of any file marked "U", "UU", or "D" without the pending changes. Is it safe for me to take the provided transaction identifier (second argument to pre-commit) and strip off the dash and any characters that follow it and consider that the "base revision"? Is there a better way to get at this information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
直接的答案是不。交易号码可以是任何东西。但是,
svnlook youngest
将返回最后的修订版本,这应该是您正在寻找的内容。小心预提交挂钩:
有时,最好使用持续集成服务器来验证提交,而不是使用预提交或提交后挂钩。例如,允许开发人员提交文件,但如果开发人员不在正确的组中,则可以向开发负责人发送电子邮件。
开发人员有 90% 的可能性做的是正确的事情。该开发主管可能已经知道这个问题。而且,如果出现问题,您可以恢复更改。
The direct answer is no. The transaction number could be anything. However,
svnlook youngest <repos>
will return the last revision which should be what you're looking for.Be careful with pre-commit hooks:
There are times when it's best to use a continuous integration server to verify the commit rather than a pre-commit or post-commit hook. For example, allow a developer to commit a file, but if the developer isn't in the right group, maybe email the development lead.
There's a 90% chance that the developer is probably doing the right thing. That development lead probably already knows about the issue. And, if there is an issue, you can revert the change.
在提交修订版之前,基本修订版尚未确定。如果另一个更改没有更改相同的节点,则可以在提交正在进行时提交它。只有提交的最后部分是独占的。
The base revision is undecided until the revision is committed. If another change doesn't change the same nodes it can be committed while your commit is in process. Only the final part of the commit is exclusive.
并且给最小的加1。
例如:
And add 1 to youngest.
e.g.: