Skip to content

Instantly share code, notes, and snippets.

@georgescumihai
Created May 18, 2020 13:16
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 georgescumihai/280bfa0096bdeceb184478ec4d7bfa99 to your computer and use it in GitHub Desktop.
Save georgescumihai/280bfa0096bdeceb184478ec4d7bfa99 to your computer and use it in GitHub Desktop.
Swiftformat pre-commit hook
#!/bin/sh
#
SWIFTFORMAT_FILEPATH=".swiftformat"
# Workaround for SourceTree
export PATH=/usr/local/bin:$PATH
git diff --diff-filter=d --staged --name-only | grep -e '\.swift$' | while read line; do
swiftformat --config $SWIFTFORMAT_FILEPATH $line "${line}";
git add "$line";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment