Created
August 24, 2021 20:23
-
-
Save billbonney/7c55bfd5c9d64e9d6f364880726a7352 to your computer and use it in GitHub Desktop.
swift-format git pre-commit hook
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 | |
if which swift-format >/dev/null; then | |
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do | |
swift-format -m format -i "${line}"; | |
git add "$line"; | |
done | |
exit 0 | |
else | |
echo "warning: swift-format not installed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment