Skip to content

Instantly share code, notes, and snippets.

@billbonney
Created August 24, 2021 20:23
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 billbonney/7c55bfd5c9d64e9d6f364880726a7352 to your computer and use it in GitHub Desktop.
Save billbonney/7c55bfd5c9d64e9d6f364880726a7352 to your computer and use it in GitHub Desktop.
swift-format git pre-commit hook
#!/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