Created
April 13, 2018 10:37
-
-
Save vdugnist/5d3afb586039510867bec4b2d90f7cff to your computer and use it in GitHub Desktop.
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 | |
function exclude_odd_folders_and_format { | |
egrep -v "^Pods|^tools" | tr '\n' '\0' | xargs -0 clang-format -i -style=file | |
} | |
export -f exclude_odd_folders_and_format | |
if [ $# -eq 0 ]; then | |
find . -type f -name *.h -o -name *.m -o -name *.mm | sed "s/^\.\///g" | exclude_odd_folders_and_format | |
exit 0 | |
elif [ "$1" == "--only-modified" ]; then | |
git status --porcelain | grep -e "^ \\?[AM]" | sed "s/^...//" | grep -E '(.*\.h|.*\.m|.*\.mm)$' | exclude_odd_folders_and_format | |
exit 0 | |
fi | |
echo "Unknown argument" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment