Last active
March 24, 2022 04:57
-
-
Save gedankenexperimenter/258d26d36085aa408c3a4f23dd839b76 to your computer and use it in GitHub Desktop.
The equivalent of how I added namespace comments to Kaleidoscope source code
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
#!/usr/bin/env bash | |
cd "${KALEIDOSCOPE_DIR}" | |
cat > .clang-format <<EOF | |
--- | |
BasedOnStyle: Google | |
--- | |
Language: Cpp | |
FixNamespaceComments: true | |
KeepEmptyLinesAtTheStartOfBlocks: true | |
ReflowComments: false | |
EOF | |
fd '.*\.(h|cpp)$' src --print0 | xargs -0 clang-format -i | |
fd '.*\.(h|cpp)$' plugins --print0 | xargs -0 clang-format -i | |
git add --all && git commit -m "temporary clang-format" | |
perl -pi -e 's/(Fix.*:) true/$1 false/' .clang-format | |
fd '.*\.(h|cpp)$' src --print0 | xargs -0 clang-format -i | |
fd '.*\.(h|cpp)$' plugins --print0 | xargs -0 clang-format -i | |
git stash push -m "clang-format namespace comments" | |
git reset --hard HEAD^ | |
git stash pop | |
# Manual review and fixup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: I did not actually run this script; I used
magit
in Emacs and edited the.clang-format
file by hand. I've been usingfd
lately instead offind
, and I was too lazy to convert it for this gist. And perl instead ofsed
because mac OSsed -i
doesn't do what you'd want it to, and I can never remember the regex syntax for it. There may be errors.