一、代码提交格式检查:
1、tar zxvfp tool.tar.gz
2、把解压的tool目录放到你的工程目录根目录
3、把pre-commit这个文件cpcopy到repo的.git/hooks/目录下.
4、执行git commit时就会执行格式检查了,如果格式不符合就会终止提交
二、代码格式化
1、//应为配置文件支持的语法是clang-format-5以上版本
sudo apt-get install clang-format-5.0
2、把tool文件中的 .clang-format 到工程目录根目录
3、cd 到工程目录
4、git config clangFormat.binary clang-format-5.0
5、git config clangFormat.stylePath ./.clang-format
(这个好像没效果)
6、格式化所有已经stage的文件
git clang-format-5.0
7、格式化整个 repo
git clang-format-5.0 --commit `git hash-object -t tree /dev/null`