排除目录clang格式 [英] exclude directory clang format
问题描述
.clang-format
文件中是否有任何正式指令排除要申请的目录?
Is there any official directive in .clang-format
file to exclude directory for applying?
项目有时使用git submodule
,但是在所有目录上运行clang-format
然后使用git checkout
撤消子模块文件夹中的更改并没有用.
Projects sometimes use git submodule
, but it is not useful to run clang-format
over all directory and then use git checkout
to undo changes in submodule folder.
我找到了一些相关链接:
I have found some related links:
但是他们似乎并不正式.
But they don't seem official.
推荐答案
到目前为止,我不知道使用clang格式的任何选项来排除文件或目录.但是我要做的是在bash脚本中创建要处理的文件列表,然后为它们调用clang-format:
So far, I don't know of any option of clang-format to exclude files or directories. But what I do, is to create the list of files I want to process in a bash script and then call clang-format for them:
#!/bin/bash
folder=.
exclude_folder=./submodule
format_files=`find "${folder}" -type f -path "${exclude_folder}" -prune
for file in $format_files
do
clang-format -i "$file"
done
在这里,魔术是通过find中的prune选项完成的. (如何在find.命令中排除目录).
Here the magic is done by the prune option in find. (How to exclude a directory in find . command).
希望这至少对您有帮助.
Hope this help you at least.
这篇关于排除目录clang格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!