简体   繁体   English

为什么Subversion在签入时会加重/重新创建文件?

[英]Why does subversion chown/recreate files on checkin?

I have a personal wiki that I take notes on. 我有一个个人维基,我在上面做笔记。 The wiki's pages are in a subversion working copy directory, "pages", and I set their permissions to 664, owned by www-data:www-data. Wiki的页面位于Subversion工作副本目录“页面”中,我将其权限设置为www-data:www-data所拥有的664。 My username is in the "www-data" group, so I can checkin and mess with the pages manually. 我的用户名位于“ www-data”组中,因此我可以手动检入并弄乱页面。

For a while, I had an issue because every time I ran a checkin, the files would be owned by me:www-data instead of www-data:www-data, and I would no longer be able to change the wiki files through my web interface! 有一阵子,我遇到了一个问题,因为每次运行签入时,文件将归我所有:www-data而不是www-data:www-data,并且我将无法再通过以下方式更改Wiki文件:我的网页界面! I solved the issue by flipping the setgid bit on the "pages" directory, but I'm still confused as to why this happened in the first place: 我通过翻转“页面”目录中的setgid位解决了该问题,但是我仍然困惑为什么会首先发生这种情况:

Every time I check something into subversion, it appears as if svn deletes it and recreates it. 每次我将某项检查到subversion中时,它似乎就像svn删除它并重新创建一样。 Why? 为什么? Does this behavior support some functionality that I'm not aware of? 这种行为是否支持我不知道的某些功能? Is there a way to change it? 有办法改变吗?

Thanks! 谢谢!

Set the "sticky" permissions bit. 设置“粘性”权限位。

find -type d -exec chgrp www-data {} + 
find -type d -exec chmod g+s {} + 

this will encourage checkout's file creation phase to inherit the directories permissions instead of switching to the person whom last edited it. 这将鼓励checkout的文件创建阶段继承目录权限,而不是切换到最后编辑它的人。

Edit : dow +s == setgid. 编辑 :陶氏+ S == setgid。 Information left here for posterity and other readers. 此处留给后代和其他读者的信息。

I think you are using it wrong. 我认为您使用错了。 What you could do is still have everything in subversion and have your local working copy separate from the www directory which you develop on. 您可以做的仍然是将所有内容都保留在subversion中,并将本地工作副本与开发所依据的www目录分开。

Then just have the www working-copy auto-updated (or exported if you don't want the .svn directories in the www foldeR) for the www-user by some script (perhaps as a post-commit hook) which then setups permissions accordingly. 然后只需使用某些脚本(可能是提交后的钩子)自动为www用户更新www工作副本(如果您不希望www foldeR中的.svn目录,则可以将其导出)。因此。

Work flow would be: 工作流程为:

  1. edit files in /home/youruser/yourwiki-working-copy/ 编辑/ home / youruser / yourwiki-working-copy /中的文件
  2. do svn commit 做svn commit
    • post-commit hook updates the files in /var/www/ (or wherever the wiki is located) 提交后钩子更新/ var / www /(或Wiki所在的位置)中的文件
  3. goto 1. 转到1。

This way, you don't have to worry about permissions and you can even have more than one person work on the web site with all the benefits of version control. 这样,您就不必担心权限问题,甚至可以让一个以上的人在网站上进行版本控制的所有好处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM