SVN 可以设置为在提交文件时发出警告吗?
今天我注意到一周前我不小心修改了一个不应该修改的文件,并将其与其余文件一起提交。这让我想到,如果你能将 SVN 中的某些文件标记为“你可能不想提交这个文件”,那就太好了。也就是说,如果我不小心修改了这样的文件,那么在提交时我会收到一个警告问题:“你真的确定要提交这个文件吗?”我不需要完全锁定,因为可能存在一些罕见的合法情况来接触这些文件。
这可以以某种方式设置吗?
Today I noticed that a week ago I had accidentally modified a file that I shouldn't and committed it with the rest of them. Which got me thinking, that it would be nice, if you could flag some files in SVN as "you probably don't want to commit this one". That is, if I do accidentally modify such a file, then at commit I would get a warning question: "Are you reeeeealy sure you want to commit this file?" I don't want a full lock, because there might be some rare legitimate cases for touching these files.
Can this be set up somehow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我会使用锁来做到这一点,您可以为每个文件添加一个锁,然后再使用您为此目的创建的特殊用户(例如notSoFast)提交。
这样,每次您尝试提交被 notSoFast 锁定的文件时,您将被禁止这样做,如果您确实需要更新该文件,您可以 (a) 以用户身份提交此文件日志记录 < em>notSoFast 或 (b) 删除用户的锁定,提交更改,然后使用用户重新锁定文件。
I would do this with locks, you can add a lock to every file you want to think twice before committing with a special user you created only for this purpose (say notSoFast).
This way every time you try to commit a file that is locked by notSoFast you will be forbidden to do so, if you really need to update that file you can (a) commit this file logging as user notSoFast or (b) remove the lock from the user, commit your changes, then relock the file with user.
我赞同 @mtrovo 告诉你的,这是另一个更难实现的选项:
TortoiseSVN 允许你(我认为从版本 1.6.x 开始)使用客户端挂钩脚本。客户端钩子脚本的调用方式与服务器端等效,但在客户端调用。您可以向文件中添加一些信息,并根据该信息添加一个对话框,询问您存储该信息是否合适。您必须执行以下步骤才能获得有效的解决方案:
svn:needs-ok
以及一些值。svn:needs-commit
,确定
和取消
。svn:needs-ok
。我不认为这是一个足够有效的解决方案,值得烦恼:-(
I would second what @mtrovo has told you, here is another option which is much more difficult to implement:
TortoiseSVN allows you (I think from version 1.6.x) to use client hook scripts. Client hook scripts are called like the server side equivalent, but on the client side. You could there add some information to your files, and depending on that information, add a dialog that asks you if the storing of the information is appropriate. You have to do the following steps to get a working solution:
svn:needs-ok
with some value.svn:needs-commit
,OK
andCancel
.svn:needs-ok
set.I don't think that this is a solution that works sufficient well to be worth the annoyance :-(
我有两个预提交挂钩,它们可能会执行您想要的操作:
第一个是我所说的“厨房水槽”挂钩,因为它可以做很多事情。您可以指定的事情之一是允许谁对特定文件进行更改。例如,您可以将这些文件设置为大多数用户的只读,但仍允许特定用户在需要时对其进行修改。这一切都由控制文件控制,因此您不必修改脚本本身。
第二个钩子是通知钩子,允许用户指定他们想要观看的文件。如果监视的文件被修改,则会向用户发送一封电子邮件。例如,技术主管可以监视这些特定文件,并在这些文件发生更改时收到通知。如果开发人员被授权修改该文件,他们可以忽略该问题。如果开发人员无权进行更改,则可以快速恢复更改。
第一种方法会阻止更改,但这意味着如果需要更改,则进行更改可能会很痛苦,因为您必须要求特定的人进行更改。在第二种方法中,仍然可能发生未经授权的更改,但责任人将很快收到通知并可以恢复更改。通常,如果开发人员知道有人正在监视他们,他们会更加小心。
这些钩子使用 Perl,但没有非标准模块,因此无需从 CPAN 下载和安装模块,这对于某些站点来说可能很困难。
I have two pre-commit hooks that might do what you want:
The first is what I call my Kitchen Sink hook because it does a lot of stuff. One of the things you can specify is who is allowed to make changes to particular files. For example,you could set these files as read-only for most users, but still allow particular users to make modifications in them when required. It's all controlled by a control file, so you don't have to modify the script itself.
The second hook is a notification hook that will allow users to specify what files they want to watch. If a watched file is modified, the user is sent an email. For example, the tech leads could watch these particular files, and get notification when these files were changed. If the developer was authorized to modify the file, they could ignore the issue. If the developer wasn't authorized to make the change, the change can quickly be reverted.
The first approach will prevent the change, but it means that if a change is required, making the change could be a pain since you have to ask a particular person to make the change. In the second approach, unauthorized changes could still take place, but whomever is responsible will quickly be notified and can revert the change. Normally, if a developer knows someone is watching them, they'll be more careful.
The hooks use Perl, but no non-standard modules, so there's no need to download and install modules from CPAN which can be difficult for some sites.
对于已经在版本控制中并且未被忽略的文件,您可以使用预提交挂钩来拒绝更改来处理此问题,但允许在注释中使用“借口”来禁用预提交挂钩。如果评论中包含“我确定因为”文本,那么它将允许提交。
For files that are already in version control and are not ignored, You could handle this using a pre-commit hook to reject the change, but allow an "excuse" in the comment that could disable the pre-commit hook. If the comment has the text "I'm sure because" then it would allow the commit.