mirror of
https://github.com/mrcsxsiq/Kotlin-Pokedex.git
synced 2025-08-06 15:00:43 +08:00
execute ktlint in git pre-commit hook
This commit is contained in:
6
install-git-hook.gradle
Normal file
6
install-git-hook.gradle
Normal file
@ -0,0 +1,6 @@
|
||||
task installGitHook(type: Copy) {
|
||||
from new File(rootProject.rootDir, 'pre-commit')
|
||||
into { new File(rootProject.rootDir, '.git/hooks') }
|
||||
fileMode 0777
|
||||
}
|
||||
preBuild.dependsOn installGitHook
|
15
pre-commit
Executable file
15
pre-commit
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
git stash -q --keep-index
|
||||
|
||||
echo "Running git pre-commit hook"
|
||||
|
||||
./gradlew ktlint
|
||||
|
||||
RESULT=$?
|
||||
|
||||
git stash pop -q
|
||||
|
||||
# return 1 exit code if running checks fails
|
||||
[ $RESULT -ne 0 ] && exit 1
|
||||
exit 0
|
Reference in New Issue
Block a user