Skip to content

Instantly share code, notes, and snippets.

@d
Last active March 14, 2018 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d/da615d358037eb741544d6c8c3352cb2 to your computer and use it in GitHub Desktop.
Save d/da615d358037eb741544d6c8c3352cb2 to your computer and use it in GitHub Desktop.
Which comments need more work for clang-format?
#!/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