Skip to content

Commit

Permalink
Merge pull request #5 from pknu-wap/chore/jaino/#4
Browse files Browse the repository at this point in the history
Chore/jaino/#4
  • Loading branch information
jeongjaino authored Sep 21, 2023
2 parents 49d1d45 + 71fc32d commit 12e2187
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ dependencies {
androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.test.espresso)
}

tasks.getByPath(":app:preBuild").dependsOn("installGitHook")

tasks.register<Copy>("installGitHook") {
dependsOn("deletePreviousGitHook")
from("${rootProject.rootDir}/script/pre-commit")
into("${rootProject.rootDir}/.git/hooks")
eachFile {
fileMode = 777
}
}

tasks.register<Delete>("deletePreviousGitHook") {
val prePush = "${rootProject.rootDir}/.git/hooks/pre-commit"
if (file(prePush).exists()) {
delete(prePush)
}
}
Empty file modified gradlew
100644 → 100755
Empty file.
12 changes: 12 additions & 0 deletions script/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
echo "Running git pre-commit hook"

./gradlew ktlintFormat --daemon

# $? = ".gradlew ktlintFormat --daemon"에 대한 return 값
STATUS=$?

# 문제없이 끝났다면 exit 0, 아니면 1
# -ne: Not equals
[ $STATUS -ne 0 ] && exit 1
exit 0

0 comments on commit 12e2187

Please sign in to comment.