Last active
March 14, 2018 01:44
-
-
Save d/da615d358037eb741544d6c8c3352cb2 to your computer and use it in GitHub Desktop.
Which comments need more work for clang-format?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -u | |
_main() { | |
cat > .clang-format <<YAML | |
--- | |
Language: Cpp | |
BasedOnStyle: Google | |
AllowShortFunctionsOnASingleLine: None | |
AlwaysBreakAfterDefinitionReturnType: true | |
BreakBeforeBinaryOperators: None | |
# BreakBeforeTernaryOperators: false | |
# BreakConstructorInitializersBeforeComma: true | |
IndentCaseLabels: true | |
MaxEmptyLinesToKeep: 3 | |
AccessModifierOffset: -4 | |
IndentWidth: 4 | |
TabWidth: 4 | |
UseTab: Always | |
BreakBeforeBraces: Allman | |
SpaceAfterCStyleCast: true | |
ReflowComments: false | |
# ForEachMacros: [ foreach ] | |
... | |
YAML | |
git ls-files --full-name :!scripts '*.cpp' '*.h' '*.inl' | parallel --quote -m clang-format -i | |
git add -u :!.clang-format | |
ruby -ryaml <<-RUBY | |
config = YAML.load_file(".clang-format").merge("ReflowComments" => true) | |
File.write(".clang-format", | |
YAML.dump(config)) | |
RUBY | |
git ls-files --full-name :!scripts '*.cpp' '*.h' '*.inl' | parallel --quote -m clang-format -i | |
ruby -ryaml <<-RUBY | |
config = YAML.load_file(".clang-format").merge("ReflowComments" => false) | |
File.write(".clang-format", | |
YAML.dump(config)) | |
RUBY | |
git diff -- :!.clang-format > reflow.diff | |
git checkout HEAD -- :!.clang-format | |
} | |
_main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment