Skip to content

Instantly share code, notes, and snippets.

@tonilopezmr
Last active August 15, 2021 10:05
Show Gist options
  • Save tonilopezmr/88f651827a924993a6692b3bde2ca755 to your computer and use it in GitHub Desktop.
Save tonilopezmr/88f651827a924993a6692b3bde2ca755 to your computer and use it in GitHub Desktop.
Pre-commit hook to run ktlint with auto-correct option and it adds the auto-correct changes into the commit.
#!/bin/sh
# https://github.com/shyiko/ktlint pre-commit hook
git diff --name-only --cached --relative | grep '\.kt[s"]\?$' | xargs ktlint -F --relative .
if [ $? -ne 0 ]; then exit 1; else git add .; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment