mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2025-12-30 16:31:29 -06:00
Pre commit hook Add (#600)
* added commands * command line improvements * remove unwanted changes
This commit is contained in:
committed by
GitHub
parent
160a67e579
commit
065378adfc
@@ -54,3 +54,11 @@ subprojects {
|
||||
//tasks.register("clean", Delete::class) {
|
||||
// delete(rootProject.buildDir)
|
||||
//}
|
||||
|
||||
// pre build gradle hook for git init on evey gradle build to reduce developer friction.
|
||||
val installGitHook by tasks.register<Exec>("installGitHook") {
|
||||
workingDir = rootProject.rootDir
|
||||
commandLine = listOf("sh", "./githooks/git-init.sh")
|
||||
}
|
||||
|
||||
tasks.getByPath("app:preBuild").dependsOn(installGitHook)
|
||||
|
||||
5
githooks/git-init.sh
Executable file
5
githooks/git-init.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Setting Git hooks"
|
||||
chmod -R +x ./githooks/
|
||||
git config core.hooksPath ./githooks/
|
||||
16
githooks/pre-commit
Executable file
16
githooks/pre-commit
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
echo "*******************************"
|
||||
echo "Running git pre-commit hook"
|
||||
echo "*******************************"
|
||||
|
||||
# Run Spotless
|
||||
./gradlew spotlessApply
|
||||
./gradlew spotlessKotlinApply
|
||||
|
||||
# Check if lint found any errors
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Spotless found some errors. Please fix them before committing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user