-
-
Save icanswiftabit/ec36397169ecea04636464c735d1af97 to your computer and use it in GitHub Desktop.
Pre commit git hook to run SwiftLint and SwiftFormat
This file contains hidden or 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 | |
# Place this file in `.git/hooks/` | |
if which swiftlint >/dev/null; then | |
swiftlint autocorrect | |
else | |
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" | |
fi | |
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do | |
swiftformat "${line}"; | |
git add "$line"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment