带有 auto-props & 的 svn 导入预提交钩子

发布于 2024-08-26 11:33:15 字数 545 浏览 2 评论 0原文

我公司的 svn 存储库中有很多 MS Word 文档。我们实施了一项政策,即所有 .doc 文件都必须设置 svn:needs-lock 属性,以防止对难以合并的文件进行并行访问(我们也对 xls、ppt、pdf 等执行了此操作)。

我们通过分发 svn 配置来实施该策略,其中自动属性为所有相关文档类型进行了适当设置。我们还设置了一个预提交挂钩,用于检查所有添加的这些类型的文件是否都设置了 Needs-Lock 属性(即,如果他们忘记/太懒于更新他们的 svn 配置文件,他们将无法将任何文档添加到存储库中)。

然而,我遇到的问题是,当用户尝试将文件导入到存储库中时,预提交挂钩会失败,例如,某些用户喜欢直接通过 TortoiseSVN 的存储库浏览器添加文件,这实际上是 svn 导入。

通过对其他文件类型的测试,我发现执行导入实际上确实应用了我的配置中列出的自动属性,但它们似乎并未在预提交挂钩运行时应用。导入 .doc 文件时,挂钩失败,表示缺少 need-lock 属性。

将单个文件添加到工作副本并提交与直接导入文件之间真的有很大区别吗?我们是否需要以某种方式定制我们的预提交挂钩来满足这种情况?

My company's svn repo has a lot of MS Word docs in it. We've implemented a policy that all .doc files must have the svn:needs-lock property set to prevent parallel access on files that are hard to merge (we've also done this for xls, ppt, pdf etc.).

We've implemented the policy by distributing a svn config with auto-props set appropriately for all relevant document types. We've also set up a pre-commit hook that checks that all added files of these types have the needs-lock property set (i.e. if they forget/are too lazy to update their svn config file, they won't be able to add any docs to the repo).

The problem I'm having, however, is that the pre-commit hook fails when users try to import files into the repo, e.g. some users like to add files directly thru TortoiseSVN's Repo Browser, which effectively is an svn import.

Through testing on other file types, I have seen that doing an import does in fact apply the auto-props listed in my config, but they don't seem to be applied at the point that the pre-commit hook runs. When importing .doc files, the hook fails, saying that the needs-lock property is missing.

Is there really much difference between adding a single file to a working copy and committing it vs importing a file directly? Do we need to tailor our precommit hook in some way to cater for this scenario?

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

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

发布评论

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

评论(1

涫野音 2024-09-02 11:33:15

解决了...也是我的错。

autoprops 定义不正确。我有这样的条目:

*.doc = svn:needs-lock

当我应该有:

*.doc = svn:needs-lock=*

即实际上为 need-lock 属性设置一个值,就像为任何其他属性(如 svn:mime-type)设置一个值一样。

令人恼火的问题是,损坏的配置对于添加操作来说效果很好。 autoprops 定义末尾缺少“=*”似乎并不重要。无论如何,该属性的 * 值似乎已被设置。

然而,当您进行导入时,Subversion 就没有那么好了,并且不会自动修复您无聊的 autoprops 设置。

我承认这是我的错,但添加和导入操作的行为应该保持一致。

Solved it...my fault too.

The autoprops were defined incorrectly. I had entries such as:

*.doc = svn:needs-lock

when I should have had:

*.doc = svn:needs-lock=*

i.e. actually set a value for the needs-lock property, as you would for any other property like svn:mime-type.

The irritating issue is that the broken config works just fine for add operations. It doesn't seem to matter that the "=*" is missing from the end of the autoprops definition. The * value of the property appears to get set anyway.

When you do an import, however, Subversion isn't as nice and doesn't fix your borked autoprops setting automatically.

I accept that this was my fault, but the behaviour should be consistent across both add and import operations.

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