Created
October 3, 2019 15:59
-
-
Save jpardogo/d18629e0f472f11317d105d2aa2c2b06 to your computer and use it in GitHub Desktop.
Pre-Push Git Hook for ktlint formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 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: https://www.youtube.com/watch?v=eysVDO2_X0s | |
# Ktlint Plugin: org.jlleitschuh.gradle:ktlint-gradle | |
echo "Checking code formatting" | |
./gradlew ktlintCheck --daemon | |
status=$? | |
if [ "$status" == 0 ] ; then | |
echo "No formatting issues were found" | |
exit 0 | |
else | |
echo>&2 "* There are code formatting issues that must be addressed" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment