Skip to content

Instantly share code, notes, and snippets.

@chrisfey
Created December 3, 2019 09:29
Show Gist options
  • Save chrisfey/53fa74e8e7265fec6cfea0cc007aceca to your computer and use it in GitHub Desktop.
Save chrisfey/53fa74e8e7265fec6cfea0cc007aceca to your computer and use it in GitHub Desktop.
pre-commit file to automatically ktlintFormat your diff
#!/bin/sh
for file in `git diff --name-only --cached --relative | grep '\.kt[s"]\?$'`; do
echo "Formatting: $file"
ktlint -F --relative $file
git add -u $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment