Visual Studio格式样式的版本控制 [英] version control over visual studio formatting style

查看:68
本文介绍了Visual Studio格式样式的版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要拥有一致的样式标准版本,应该怎么做?我想实现两件事:

What's the way to go if I want to have a consistent style standard versioned? I want to achieve two things:

  1. ctrl-k,ctrl-f (自动缩进)会基于共享标准来格式化代码
  2. Stylecop违反共享规则
  1. Pressing ctrl-k,ctrl-f (auto indenting) formats the code based on a shared standard
  2. Stylecop runs against shared rules

要实现此目的,我必须在git存储库中添加哪些文件?

What files do I have to add in my git repository to achieve this?

推荐答案

您可以添加 预提交挂钩.

You can add a pre-commit hook.

您可以在项目根目录的git repo版本中创建一个钩子脚本(例如 pre-commit.sh ),并在 README/documentation 鼓励所有开发人员使用它.

You can version in your git repo a hook script (say pre-commit.sh) at the root of your project and include the installation instructions in your README/documentation to encourage all developers use it.

安装无非是:

ln -s ../../pre-commit.sh .git/hooks/pre-commit

如文章"使用git的提示预提交钩子",您需要在该钩子中确保未在预提交脚本中测试不属于预期提交的代码:

As the article "Tips for using a git pre-commit hook", you need, in that hook, to ensure that code that isn't part of the prospective commit isn't tested within your pre-commit script:

# pre-commit.sh
git stash -q --keep-index

# Test prospective commit
# call format, stylecop...

git stash pop -q

这篇关于Visual Studio格式样式的版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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