在预提交中确定事务的基础修订版

发布于 2024-12-28 16:34:25 字数 180 浏览 2 评论 0原文

我正在编写一个预提交挂钩,我想在事务之前根据文件的内容强制执行一些规则。因此,当事务开始时,我想 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 技术交流群。

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

发布评论

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

评论(3

情话墙 2025-01-04 16:34:25

直接的答案是。交易号码可以是任何东西。但是,svnlook youngest 将返回最后的修订版本,这应该是您正在寻找的内容。

小心预提交挂钩:

  • 确保您没有做一些需要很长时间的事情。开发人员必须等待预提交挂钩完成,如果需要 7 到 10 秒处理某些内容,开发人员会感到非常沮丧。
  • 您不能(也不应该)更改正在提交的数据。如果它符合您的要求,请允许提交。如果不存在,则不允许提交。
  • 确保您不会停止合法活动。例如,某些站点使用预提交挂钩来防止某人提交更改,除非他们在提交消息中放入票证,并且该提交消息是分配给该开发人员的票证,并且该票证处于打开状态。您能想象当开发人员因为票证被分配给其他人而无法提交更改并且唯一可以更改分配的人本周休假时会发生什么热闹的事情吗?

有时,最好使用持续集成服务器来验证提交,而不是使用预提交或提交后挂钩。例如,允许开发人员提交文件,但如果开发人员不在正确的组中,则可以向开发负责人发送电子邮件。

开发人员有 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:

  • Make sure that you're not doing something that will take a long time. Developers have to wait for a pre-commit hook to complete, and if you take 7 to 10 seconds processing something, developers get very frustrated.
  • You cannot (and should not) change the data being committed. If it matches what you want, allow the commit. If it doesn't, don't allow the commit.
  • Make sure you aren't going to stop what could be legitimate activity. For example, some sites use pre-commit hooks to prevent someone from committing a change unless they put a ticket in the commit message, and that commit message is a ticket assigned to that developer, and that ticket is in the open state. Can you imagine the hilarity that ensues when a developer can't commit a change because a ticket is assigned to someone else, and that the only person who can change the assignment is off for the week?

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.

╭⌒浅淡时光〆 2025-01-04 16:34:25

在提交修订版之前,基本修订版尚未确定。如果另一个更改没有更改相同的节点,则可以在提交正在进行时提交它。只有提交的最后部分是独占的。

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.

遗失的美好 2025-01-04 16:34:25

并且给最小的加1。
例如:

the_revision=$(svnlook youngest ${REPOS})
((the_revision++))

And add 1 to youngest.
e.g.:

the_revision=$(svnlook youngest ${REPOS})
((the_revision++))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文