如何在 Mercurial 中验证和强制执行提交消息?

发布于 2024-12-05 19:51:22 字数 730 浏览 1 评论 0原文

使用一组正则表达式验证提交消息需要哪些步骤? 我们希望在半集中式设置中工作,因此我需要一个针对开发人员克隆(本地存储库)和中央克隆(全局存储库)的解决方案。我读到了 Mercurial Hooks 但我有点迷失如何将所有东西放在一起。

对于本地存储库,我需要一种在开发人员之间分发验证脚本的方法。我知道克隆时钩子不会传播,所以我需要一种方法在每个新克隆中“启用”它们。它将作为我们在每个干净克隆上运行的 PrepareEnvironement.bat 脚本的一部分完成。

为了双重安全,我需要对我的全局存储库进行类似的验证。不应该将未验证的全局存储库提交推入。我可以手动配置它 - 这是一次性的工作。

我使用的是 Windows,因此不需要安装除 TortoiseHG 之外的任何内容。部署 Mercurial 已经是一场斗争。不欢迎任何其他依赖项。

What are all steps required to validate commit message with set of regular expressions?
We want to work in semi-centralized set-up so I need a solution for the developer clone (local repository) and for our central clone (global repository). I read about Mercurial Hooks but I am a little bit lost how to put all things together.

For local repository I need a way to distribute validation script across my developers. I know that hooks do not propagate when cloning so I need to a way to "enable" them in each fresh clone. It would be done as a part of our PrepareEnvironement.bat script that we run anyway on each clean clone.

To be double safe I need similar validation on my global repository. It should not be possible to push into global repository commit that are not validating. I can configure it manually - it is one time job.

I am on Windows so installing anything except TortoiseHG should not be required. It was already a fight to get Mercurial deployed. Any other dependencies are not welcomed.

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

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

发布评论

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

评论(1

梦境 2024-12-12 19:51:22

您可以使用拼写检查示例作为起点。在每个开发人员的配置中,您需要使用以下钩子:

pretxnchangegroup - 在一组变更集从另一个存储库引入本地之后但在其永久化之前运行。

pretxncommit - 在本地创建新变更集之后但在其永久生效之前运行。

对于集中式存储库,我认为您只需要 pretxnchangegroup 挂钩,除非提交也可以在服务器上发生。但是,如果远程存储库被拒绝,则每个开发人员都需要 Histedit 扩展正在推送的一个或多个变更集。此扩展允许他们“编辑”已经提交的变更集。我认为在大多数情况下,本地钩子会解决这个问题,但就像你说的,“以防万一”。

更多有关使用钩子处理事件的详细信息可以在Hg Book中找到。

You can use the Spellcheck example as a starting point. In each developer's configuration, you need to use the following hooks:

pretxnchangegroup - Runs after a group of changesets has been brought into local from another repository, but before it becomes permanent.

pretxncommit - Runs after a new changeset has been created in local, but before it becomes permanent.

For the centralized repo, I think you only need the pretxnchangegroup hook unless commits can happen on the server, too. However, you will need the Histedit extension for each of the developers if the remote repo is the one rejecting one or more of the changesets being pushed. This extension allows them to "edit" already committed changesets. I would think in most cases, the local hooks will catch the issue, but like you said, "just in case."

More details about handling events with hooks can be found in the Hg Book.

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