签入时SVN自动代码格式化? [英] SVN automatic code formatting on check in?

查看:41
本文介绍了签入时SVN自动代码格式化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能吗?如果是这样,我该怎么做?

Is this possible? If so how do I do this?

代码是用 C# 编写的,我们使用的是 TortoiseSVN.

The code is in C# and we are using TortoiseSVN.

我只想在每次检查时自动格式化代码.

I simply want to auto format the code on every checking.

非常感谢

推荐答案

您正在触及圣战领域.与人们的格式打交道是要求干草叉和火炬.

You're touching on holy-war ground. Mussing with people's formatting is asking for pitchforks and torches.

我的建议:不要.

更不用说,如果您说的是 C#,并且您的开发人员使用的是 Visual Studio,那么 VS 有很多自动格式化工具.只需输入关闭的花括号,VS 就可以/将自动格式化您的代码.

Not to mention, if you're talking C#, and your developers are using Visual Studio, VS has a lot of auto-formatting tools. Just by entering that closing curly-brace and VS can/will auto-format your code.

更好的解决方案可能是让所有开发人员使用相同的自动格式化设置.

A better solution may be to get all your developers to use the same auto-formatting settings.

工具 -> 选项,文本编辑器 -> C# -> 格式

Tools -> Options, Text Editor -> C# ->Formatting

这些设置是可导出的,所以如果你能让团队同意在 VS 中使用相同的代码格式设置,你就可以避免在你的源代码控制系统中执行它的麻烦,最好由它来做它所做的最好.

These settings are exportable, so if you can get the team to agree to use the same code-formatting settings in VS, you can avoid the trouble of performing it in your source control system which is better left to do what it does best.

如果您执意要这样做,就像其他人所说的那样,预提交钩子就是您要走的路.如果您的 SVN 服务器在 Windows 上运行,我可以推荐 CaptainHook 来编写钩子脚本吗?您可以使用任何 .NET 语言编写的可插入挂钩脚本.

If you're hell-bent on doing this, a pre-commit hook, like others have said, is the way to go. If you're SVN server is running on Windows, might I recommend CaptainHook for writing your hook scripts? Plugin-able hookscripts that you can write in any .NET language.

这篇关于签入时SVN自动代码格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆