不践踏 svn 责任的样式清理?
我想使用 Eclipse 的格式化程序来修复一些样式不佳的代码,但是删除存储库中有关谁负责什么的所有元数据有一个巨大的缺点。 关于解决这个问题的方法有什么想法吗? 或许这根本就是不可能的事情……
I'd like to use Eclipse's formatter to fix some poorly styled code, but there's a huge downside to killing all the metadata in the repository about who is responsible for what. Any thoughts on ways to get around this? Perhaps it is just completely impossible...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以告诉blame忽略空白更改:
当然,只有当您的样式修复更改不超过空白时,这才有效。
You can tell blame to ignore whitespace changes:
Of course that only works if your style fix doesn't change more than whitespaces.
历史仍然存在,您只需要在清理修订之前查看责任即可。
这是制定风格标准的一个很好的理由。 缩进更改可能会导致大量合并冲突等。对一个人来说“风格不佳”对另一个人来说却写得很好。
The history is still there, you'll just have to look at a blame prior to the cleanup revision.
This is one good reason to have a style standard. Indentation changes can cause a lot of merge conflicts, etc. "Poorly styled" to one is well written to another.
另一种解决方案是添加一个预提交挂钩,将提交的文件与其格式化版本进行比较。 如果没有差异,则接受提交。
否则,一条简单的消息“代码未格式化:提交被拒绝”将通知您的开发人员在提交之前设置其修改文件的样式。
结合Stefan的回答,您仍然可以使用 -w 选项的blame,而且,您不会覆盖开发人员的名称。
一个缺点是您无法一次性设置整个存储库的样式。 文件将在修改时设置样式。 经常使用的文件将被快速设置样式,而有些文件可能永远不会更新。
Another solution would be to add a pre-commit hook that compare the committed file with its formatted version. If there is no difference, the commit is accepted.
Otherwise, a simple message "Code not formatted : commit rejected" would inform your developers to style their modified files prior to commit.
Combined with the Stefan's answer, you still can use blame with -w option and moreover, you do not override the developer's names.
One drawback is that you won't be able to style your whole repository is one pass. Files will be styled as they are modified. Often used files will be quickly styled whereas some might never been updated.
当重新格式化代码时,我通常只修复缩进。 在很多情况下,自动格式化程序会毁掉精心手工格式化的部分。
When reformatting code, I usually only fix the indentation. There are just too many cases where the automatic formatter ruins a carefully hand-formatted section.