如何防止用户将二进制文件提交到 subversion 中?
我有一个任性的用户,他顽固地坚持将他的二进制文件(可执行文件、DLL)提交到我们的颠覆存储库中。我会进去删除它们,但当然,颠覆中没有真正删除任何内容。
虽然有时我们需要提交二进制文件,但我不希望用户将其视为例行公事。我可以设置一个忽略属性,但这并不能阻止用户提交二进制文件(如果他们真的确定了)。我想要做的是能够逐个目录地控制提交指定文件类型的能力,特别是 .exe 和 .dll 文件。
在SVN中有没有办法做到这一点?如果有什么区别的话,我们使用 VisualSVN 服务器和 TortoiseSVN。
I have a headstrong user who stubbornly insists on committing his binaries (executables, DLLs) into our subversion repositories. I'd go in and delete them, but of course nothing is ever really deleted from subversion.
While there are times when we need to commit binaries, I don't want users doing it as a matter of routine. I can set an ignore property but that doesn't prevent users from committing binaries if they are really determined. What I'd like to do is be able to control the ability to commit nominated file types, particularly .exe and .dll files, on a directory-by-directory basis.
Is there a way to do that in SVN? If it makes any differentce, we are using VisualSVN server and TortoiseSVN.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
Tim:
你可以尝试这个 python hook 脚本。它(松散地)基于上面的,但允许拒绝路径的正则表达式模式,并允许通过
包含以Overide:
在日志消息中 开头的行来覆盖检查。它使用新的 python 打印语法,因此需要相当新的 python 版本(2.6+?)。
Tim:
You might try this python hook script. It is (loosely) based on the one above, but allows regular expression patterns for the reject paths and allows overriding the check by having a line that begins
Overide:
in the log message. It uses the new python print syntax, so it requires a fairly recent version of python (2.6+?).
这是一个小钩子脚本,它正在执行您想要的操作:
你必须配置两件事:
Here is a small hooks script which is doing what you want:
You have to configure 2 things:
编写一个预提交挂钩来检查添加的文件是否符合您的标准。
您可以使用 预提交-check.py 作为起点。
Write a pre-commit hook that checks added files whether they fit your criteria.
You could use pre-commit-check.py as a starting point.
在 TortoiseSVN 上,您可以让用户将 .dll、.exe 等添加到忽略列表中。这样,用户就不会意外签入。请参阅此处了解更多信息:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-ignore.html
在服务器端,正如其他人所说,您可以使用挂钩脚本。
On TortoiseSVN you can have the user add .dll, .exe, etc to the ignore list. That way, they user won't accidentally check them in. See here for more info:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-ignore.html
On the server side, as others have stated, you can use a hook script.
您可以使用预提交 钩子。您必须编写一个简单的程序(用任何语言),如果文件是二进制文件,它会返回非零值。
请参阅此处有关存储库挂钩的通用文档,以及 此处 查看来自 Apache 的 Python 示例。
您可以查看文件名,或使用 file 查看其类型。
You can use a pre-commit hook. You'll have to write a simple program (in any language) which returns a non-zero value if the file is binary.
See here for generic documentation about repository hooks, and here for a python example from Apache.
You could look at the files names, or use file to look at their types.
您可以使用 svnlook 命令。这是一个执行此工作的 python 类:
tx_files() 方法返回一个包含如下信息的地图:
您将需要库 python-magic (https://github.com/ahupp/python-magic)
You can use svnlook command. Here is a python class that do this job:
tx_files() method returns a map with info like this:
You will need the library python-magic (https://github.com/ahupp/python-magic)
您可以使用预提交挂钩脚本来检查文件是二进制文件还是文本文件。
You could use a pre-commit hook script that checks if the file is binary or textual.