From c2c7febdffe5a18d2a91ddca8bba20b78bd1f9b3 Mon Sep 17 00:00:00 2001 From: KotlinIsland Date: Wed, 28 Apr 2021 10:51:24 +1000 Subject: [PATCH] git hook: fix formatting issue --- .../kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt index 658316e1..7c735975 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt @@ -65,7 +65,7 @@ private fun postCheck( git add ${'$'}file fi done - """.trimIndent() + """.trim('\n', ' ') } else { "" } @@ -79,28 +79,29 @@ internal fun generateGitHook( gradleRootDirPrefix: String ) = """ - + CHANGED_FILES="${'$'}(${generateGitCommand(gradleRootDirPrefix)} | awk '$1 != "D" && $NF ~ /\.kts?$/ { print $NF }')" - + if [ -z "${'$'}CHANGED_FILES" ]; then echo "No Kotlin staged files." exit 0 fi; - + echo "Running ktlint over these files:" echo "${'$'}CHANGED_FILES" git stash push --keep-index ${generateGradleCommand(taskName, gradleRootDirPrefix)} - + echo "Completed ktlint run." + ${postCheck(shouldUpdateCommit)} git stash pop echo "Completed ktlint hook." - + """.trimIndent() internal fun KtlintPlugin.PluginHolder.addGitHookTasks() {