From ef26f2b7954c673554163c30b63e84956904df93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=EC=9B=90?= Date: Tue, 23 Jul 2024 23:15:06 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20windows=20=ED=99=98=EA=B2=BD=EC=97=90?= =?UTF-8?q?=EC=84=9C=EB=8F=84=20pre-commit=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EC=8B=A4=ED=96=89=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 11 +++++------ scripts/pre-commit.sh | 7 ++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 48485647..86be2970 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -93,15 +93,14 @@ tasks.register("updateGitHooks") { from("scripts/pre-commit.sh") into(".git/hooks") rename("pre-commit.sh", "pre-commit") -} - -tasks.register("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") { diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh index 3a0a3cbd..3588efd5 100755 --- a/scripts/pre-commit.sh +++ b/scripts/pre-commit.sh @@ -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