如何在 BZR 中编写特定于分支的钩子?

发布于 2024-08-22 05:43:02 字数 677 浏览 3 评论 0原文

在 Subversion 中,挂钩是基于每个存储库编写的。每个钩子都以描述性文件名(例如预提交)写入存储库根目录中名为“hooks”的文件夹中。根据 BZR 文档,钩子通常是全局安装的(例如在 ~/.bazaar/plugins/ 目录中)。

例如,是否可以创建一个提交到分支并且无需用户安装插件即可运行的预提交挂钩?

我在文档和一些代码讨论中看到了对“分支挂钩”的引用,这听起来很有希望。

我找到了这个博客: http://schettino72.wordpress.com/2008/01/20/how-to-execute-tests-on-a-bazaar-pre-commit-hook/,其中引用:

“集市中的插件不是项目 具体的。所以你无法控制其中 您的插件将的项目(分支) 被应用(它将被应用到 全部)。”

这是不太有希望的。该博客提供了一种解决方法,您可以编写并安装一个插件,该插件可以调用存储库中存在的挂钩。理想情况下,我不想依赖用户安装插件来实现真正基本的挂钩运行,即一个简单的测试,这可能吗?

In subversion, hooks are written on a per-repository basis. Each hook is written in a descriptive filename (e.g. pre-commit) in a folder named "hooks" at the root of the repository. According to the BZR docs, hooks are typically installed globally (e.g. in the ~/.bazaar/plugins/ directory).

Is it possible to create, say, a pre-commit hook that is committed to the branch and that runs without a user having to install a plugin?

I see in the docs and in some code discussions a reference to something called "branch hooks," which sounds promising.

I found this blog: http://schettino72.wordpress.com/2008/01/20/how-to-execute-tests-on-a-bazaar-pre-commit-hook/, which quotes:

"plugins in bazaar are not project
specific. so you cant control in which
projects (branches) your plugin will
be applied (it will be applied to
all)."

which is less promising. The blog gives a workaround in that you write and install a plugin that calls hooks in your repository if they exist. Ideally, I want not to rely on users to install plugins for a really basic hook to run, namely a simple test. Is this possible?

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

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

发布评论

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

评论(3

朦胧时间 2024-08-29 05:43:02

您可以使用集市服务器并在其上安装挂钩。

您还可能会找到感兴趣的下一个链接:

http://people.samba .org/bzr/jelmer/bzr-shell-hooks/trunk/

http://bazaar.launchpad.net/~stianse/%2Bjunk/bzr-shell-hooks/

You can use bazaar server and install hooks on them.

also You may find interested next links:

http://people.samba.org/bzr/jelmer/bzr-shell-hooks/trunk/

http://bazaar.launchpad.net/~stianse/%2Bjunk/bzr-shell-hooks/

暮凉 2024-08-29 05:43:02

我对此进行了一些研究,发现分布式修订控制系统中缺乏特定于分支的挂钩背后的动机。我将 Subversion(一种集中式 RCS)进行了比较,作为所需功能的示例。

GIT 和 Mercurial 是分布式 RCS(如 Bazaar),它们具有用于钩子的工具,包括针对特定于分支的钩子和全局钩子的不同方法。无论如何,这些挂钩不受版本控制,并且由于存在安全风险,它们需要分支的用户启用它们。在 有关挂钩的 Mercurial 文档 下标题为“钩子和安全性”的部分说:

在 Mercurial 中,挂钩不是修订版
受控,并且不会传播
您克隆或从存储库中提取。
原因很简单:一个钩子
是完全任意的一块
可执行代码。它在你的下面运行
用户身份,具有您的特权
级别,在您的机器上。

对于任何人来说这都是极其鲁莽的
分布式版本控制系统
实施版本控制的钩子,
因为这将提供一个容易
可利用的方式颠覆
修订版用户帐户
控制系统。

在集中式 RCS 中,例如 Subversion,挂钩在存储库服务器上运行,因此用户权限和服务器设置限制了破坏性挂钩脚本的影响。在分布式 RCS 中,钩子通常在用户的本地计算机上运行,​​这是有风险的。

正如vitaly.v.ch提到的,Bazaar服务器可以设置为在推送和拉出时运行钩子。但是预提交挂钩就没有意义了,因为提交发生在用户的计算机上。它更像是一个预推钩。

Bazaar 具有钩子所需的所有功能,但由于它们带来的安全风险,需要单独的用户配置才能安装和启用它们。

I did some research into this and found motivation behind the lack of branch-specific hooks in distributed revision control systems. I had compared to Subversion, a centralized RCS, as an example of the desired feature.

GIT and Mercurial are distributed RCSs (like Bazaar) that have tools for hooks, including different approaches to branch-specific hooks and global hooks. Regardless, the hooks are not revision controlled and they require the user of the branch to enable them due to the security risk. In the Mercurial documentation on hooks, under the section titled "Hooks and security," it says:

In Mercurial, hooks are not revision
controlled, and do not propagate when
you clone, or pull from, a repository.
The reason for this is simple: a hook
is a completely arbitrary piece of
executable code. It runs under your
user identity, with your privilege
level, on your machine.

It would be extremely reckless for any
distributed revision control system to
implement revision-controlled hooks,
as this would offer an easily
exploitable way to subvert the
accounts of users of the revision
control system.

In a centralized RCS, like Subversion, the hooks are run on the repository server, so user permissions and server-setup restrict the impact of a damaging hook script. In a distributed RCS, the hooks are typically run on the user's local machine, which is risky.

As vitaly.v.ch mentions, a Bazaar server could be setup to run hooks when pushed to and pulled from. But then a pre-commit hook doesn't make sense, since the commits happen on the user's machine. It would then be more like a pre-push hook.

Bazaar has all the needed functionality for hooks, but individual user configuration is required to install and enable them due to the security risk they pose.

风轻花落早 2024-08-29 05:43:02

不可以,您的用户必须安装插件才能激活您的挂钩。

No, your users have to install the plugin to activate your hook.

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