我发现最佳做法是让所有文本文件都具有svn:eol-style=native
属性集.但是最有效的方法是什么?
我主要在Windows上开发程序(使用TortoiseSVN和svn.exe
命令行),有时为Windows和Linux编写可移植的C/C++库.为了防止我的源文件中令人讨厌的混合CR,LF问题,我认为svn:eol-style=native
应该是"默认",但不幸的是它不是.
我从Subversion红皮书知道配置[auto-props]
中~/.subversion/config
或%APPDATA%\Subversion\config
帮助,但是,它是每个客户端的设置.我团队中的某些开发人员忘记配置这些配置文件(考虑多个虚拟机上的dev)怎么样?即使所有人都记得,如果出现一些新的文本文件扩展名怎么办?如何将此更改正确地传播到我团队中所有dev计算机上的所有配置文件?
一切似乎都是一个繁琐的过程.
Laz*_*ger 22
我团队中的某些开发人员忘记配置这些配置文件(考虑多个虚拟机上的dev)怎么样?
只是修复错误.
如果您发现错误签入的文件,则修复起来并不难.首先,将文件更改为适合您平台的行结束样式.任何编程编辑器都应该能够使用一些内置命令切换样式,或者您可以使用'fromdos'或'todos'类型实用程序.修复后,设置属性并将其检入:
svn propset svn:eol-style native filename
svn commit filename
Run Code Online (Sandbox Code Playgroud)
我的评论副本:
另一个建议是使用预提交钩子,检查svn:eol样式设置(和存在)并在需要时修复
这应该是一个快速的答案,而不是"深入细节并自己动手,这里是链接"版本.
我们只是去做,好吗?对于颠覆1.8+:
$ cd my_checkout_dir
$ svn propset svn:auto-props '
### src
*.c = svn:eol-style=native
*.cpp = svn:eol-style=native
*.h = svn:eol-style=native
*.pch = svn:eol-style=native
*.lua = svn:eol-style=native
*.py = svn:eol-style=native
*.pl = svn:eol-style=native
*.txt = svn:eol-style=native
*.sh = svn:eol-style=native;svn:executable
### ui
*.xib = svn:eol-style=native
*.ui = svn:eol-style=native
*.qrc = svn:eol-style=native
### project
*.pro = svn:eol-style=native
*.pbxproj = svn:eol-style=native
*.json = svn:eol-style=native
*.xcworkspacedata = svn:eol-style=native
*.plist = svn:eol-style=native
' .
$ svn commit -m 'Got really tired of svn:eol-style issues'
Run Code Online (Sandbox Code Playgroud)
请注意最后关闭单引号和点(即当前目录).根据您的需要调整此列表,复制svn propset svn:auto-props '…' .
到unix/msys sh-terminal(是的,使用Enters).提交后,下面的所有文件my_checkout_dir
将在添加时继承相应的属性.在此操作之前添加的文件将不会被修改.如您所见*.sh
,您可以通过添加更多属性;
.如果要更改列表,只需重复所有内容即可.
以下是svn在我的建议中提供的默认值~/.subversion/config
:
### The format of the entries is:
### file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?'). All entries which match (case-insensitively) will be
### applied to the file. Note that auto-props functionality
### must be enabled, which is typically done by setting the
### 'enable-auto-props' option.
# *.c = svn:eol-style=native
# *.cpp = svn:eol-style=native
# *.h = svn:keywords=Author Date Id Rev URL;svn:eol-style=native
# *.dsp = svn:eol-style=CRLF
# *.dsw = svn:eol-style=CRLF
# *.sh = svn:eol-style=native;svn:executable
# *.txt = svn:eol-style=native;svn:keywords=Author Date Id Rev URL;
# *.png = svn:mime-type=image/png
# *.jpg = svn:mime-type=image/jpeg
# Makefile = svn:eol-style=native
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
22883 次 |
最近记录: |