Skip to content

Commit

Permalink
git hook: fix formatting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Apr 28, 2021
1 parent b398c9a commit f6f315b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private fun postCheck(
git add ${'$'}file
fi
done
""".trimIndent()
""".trim('\n', ' ')
} else {
""
}
Expand All @@ -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() {
Expand Down

0 comments on commit f6f315b

Please sign in to comment.