Skip to content

Instantly share code, notes, and snippets.



Created Oct 3, 2019
What would you like to do?
Pre-Push Git Hook for ktlint formatting
# Place this hook in the repo .git/hooks folder.
# make sure you chmod a+x this hook in terminal.
# Otherwise, you'll tear your hair out when you think it should run but it doesn't.
# Video Pre-Push Git Hook for ktlint Formatting With Plugin:
# Ktlint Plugin: org.jlleitschuh.gradle:ktlint-gradle
echo "Checking code formatting"
./gradlew ktlintCheck --daemon
if [ "$status" == 0 ] ; then
echo "No formatting issues were found"
exit 0
echo>&2 "* There are code formatting issues that must be addressed"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment