-
-
Save benweizhu/6404275b528a085835d3ad33c00dc205 to your computer and use it in GitHub Desktop.
Gradle auto-installing pre-commit hook
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
apply from: rootProject.file('gradle/install-git-hooks.gradle') |
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
task installGitHooks(type: Copy) { | |
from new File(rootProject.rootDir, 'pre-commit') | |
into { new File(rootProject.rootDir, '.git/hooks') } | |
} | |
build.dependsOn installGitHooks |
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 | |
# From gist at https://gist.github.com/chadmaughan/5889802 | |
# stash any unstaged changes | |
git stash -q --keep-index | |
# run the tests with the gradle wrapper | |
./gradlew test | |
# store the last exit code in a variable | |
RESULT=$? | |
# unstash the unstashed changes | |
git stash pop -q | |
# return the './gradlew test' exit code | |
exit $RESULT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment