Skip to content

Commit

Permalink
Fix: windows 환경에서도 pre-commit 스크립트를 실행하도록 수정 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewon-pro authored Jul 23, 2024
1 parent 530b2ae commit ef26f2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 5 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ tasks.register<Copy>("updateGitHooks") {
from("scripts/pre-commit.sh")
into(".git/hooks")
rename("pre-commit.sh", "pre-commit")
}

tasks.register<Exec>("makeGitHooksExecutable") {
commandLine("chmod", "+x", ".git/hooks/pre-commit")
dependsOn("updateGitHooks")
doLast {
val preCommitHook = file(".git/hooks/pre-commit")
preCommitHook.setExecutable(true, false)
}
}

tasks.compileJava {
dependsOn("makeGitHooksExecutable")
dependsOn("updateGitHooks")
}

tasks.register("projectTest") {
Expand Down
7 changes: 6 additions & 1 deletion scripts/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ stagedFiles=$(git diff --staged --name-only)

# Part 2
echo "Running spotlessApply. Formatting code..."
cd "$PROJECT_ROOT" && ./gradlew spotlessApply

if [ "$OS" = "Windows_NT" ]; then
cd "$PROJECT_ROOT" && ./gradlew.bat spotlessApply
else
cd "$PROJECT_ROOT" && ./gradlew spotlessApply
fi

# Checking the exit status
if [ $? -ne 0 ]; then
Expand Down

0 comments on commit ef26f2b

Please sign in to comment.