Skip to content

Commit

Permalink
Remove hook fix, moved to JetBrains#2943
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Feb 13, 2025
1 parent 6f178db commit 977b24c
Showing 1 changed file with 34 additions and 40 deletions.
74 changes: 34 additions & 40 deletions platform/jewel/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,51 +64,45 @@ gradleEnterprise {
val isWindows
get() = System.getProperty("os.name").contains("win", true)

val gradleCommand: String by
lazy(LazyThreadSafetyMode.NONE) {
val gradlewFilename =
if (isWindows) {
"gradlew.bat"
} else {
"gradlew"
}

val gradlew = File(rootProject.projectDir, gradlewFilename)
if (gradlew.exists() && gradlew.isFile && gradlew.canExecute()) {
logger.info("Using gradlew wrapper at ${gradlew.invariantSeparatorsPath}")
gradlew.invariantSeparatorsPath
} else {
"gradle"
}
}

val shebang = if (isWindows) "" else "#!/bin/sh"

/*
// This is broken on Windows, please do not enable it again until it is fixed.
gitHooks {
hook("pre-push") {
if (!isWindows) {
from(shebang) {
"""
|set -x
|#### Note: this hook was autogenerated. You can edit it in Jewel's settings.gradle.kts
|GRADLEW="./gradlew"
|OLD_DIR=$(pwd)
|cd "${rootDir.absolutePath}"
|if ! ${'$'}GRADLEW ktfmtCheck ; then
| ${'$'}GRADLEW ktfmtFormat
| echo 1>&2 "\nktfmt found problems; commit the result and re-push"
| cd ${'$'}OLD_DIR
| exit 1
|fi
|cd ${'$'}OLD_DIR
|
"""
.trimMargin()
}
} else {
// TODO @jakub fix this for Windows — the following _should_ work but I can't test it
// from(shebang) {
// """
// |:: Note: this hook was autogenerated. You can edit it in Jewel's settings.gradle.kts
// |SET GRADLEW=gradlew.bat
// |
// |SET OLD_DIR=%CD%
// |CD /D ${rootDir.absolutePath}
// |%GRADLEW% ktfmtCheck || (
// | %GRADLEW% ktfmtFormat
// | echo "ktfmt found problems; commit the result and re-push"
// | CD /D %OLD_DIR%
// | EXIT 1
// |)
// |
// |CD /D %OLD_DIR%
// """
// .trimMargin()
// }
from(shebang) {
// language=Shell Script
"""
|#### Note: this hook was autogenerated. You can edit it in settings.gradle.kts
|GRADLEW=$gradleCommand
|if ! ${'$'}GRADLEW ktfmtCheck ; then
| ${'$'}GRADLEW ktfmtFormat
| echo 1>&2 "\nktfmt found problems; commit the result and re-push"
| exit 1
|fi
|
"""
.trimMargin()
}
}
createHooks(overwriteExisting = true)
}
}*/

0 comments on commit 977b24c

Please sign in to comment.