【问题标题】:Change a Subversion file so it can never be modified更改 Subversion 文件,使其永远不会被修改
【发布时间】:2011-12-01 15:28:20
【问题描述】:

是否可以更改存储在 Subversion 中的文件以使其永远无法修改?我们有一个文件需要存储在系统中,但没有用户可以更新它。

【问题讨论】:

  • 你不能锁定这个文件吗?
  • 我相信锁可以被打破。

标签: svn


【解决方案1】:

您可以创建一个 pre-commit 挂钩,拒绝任何包含该文件的提交。

Implementing Repository Hooks

【讨论】:

    【解决方案2】:

    我看到您已经接受了答案,但我有一个 Perl pre-commit hook 可以满足您的需求。您所要做的就是在控制文件中发送一个条目:

    [file You are not allowed to modify this file]
    file = /the/file/you/cannot/modify.txt
    access = read-only
    users = @ALL
    

    顺便说一句,你应该创建一个可以修改这些文件的管理员组,这样你就不用修改钩子了:

    ; Creates a group of users who are allowed to modify read-only files
    [group admins]
    users = firedragon, bob, ted, carol, alice
    
    [file Only Admins are allowed to modify this file]
    file = /the/file/you/cannot/modify.txt
    access = read-only
    users = @ALL
    
    ; Order is important. The last entry that matches
    ; the file is the one implemented
    [file Only Admins are allowed to modify this file]
    file = /the/file/you/cannot/modify.txt
    access = read-write
    users = @admins
    

    您可以使用 Ant 样式的 glob 或 Perl 正则表达式指定一组文件,访问控制可以是 read-writeread-onlyno-deleteadd-only,这非常适合标记。用户可以创建标签,但不能修改。

    [file You can create a tag, but not modify it]
    file = /tags/**
    access = read-only
    users = @ALL
    
    [file You can create a tag, but not modify it]
    file = /tags/*/
    access = add-only
    users = @ALL
    

    第一个删除了在整个标签目录树中任何地方写入的所有能力。第二种允许用户直接在/tags/目录下添加标签。

    顺便说一下,你应该创建一个可以修改这些文件的管理员组,这样你就不用改钩子了:

    【讨论】:

    • 很棒的评论。我已经标记了你,希望我能做更多:-/
    【解决方案3】:

    您可以使用svn lock,但其他用户可以强制解除锁定。最好的方法是使用一个会拒绝修改文件的钩子。

    这些文章应该可以帮助您:

    【讨论】:

    • 感谢您的信息。看来这是要走的路。我给了你一个 +1,但詹姆斯首先给出了相同的答案,所以接受了他的答案。
    【解决方案4】:

    我认为答案是肯定的和否定的。是的,您可以lock 文件,而永远不能unlock 用于其他用户。从某种意义上说,如果您unlock 文件,另一个用户可以modify 它,则不。由您自己来找到正确的答案选择。

    【讨论】:

      猜你喜欢
      • 2014-11-06
      • 1970-01-01
      • 2013-07-20
      • 2011-06-12
      • 2018-11-30
      • 2021-09-30
      • 1970-01-01
      • 1970-01-01
      • 2020-05-27
      相关资源
      最近更新 更多