Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JEWEL] Fix the git hook on non-Windows OSes #2943

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 40 additions & 39 deletions platform/jewel/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,50 +65,51 @@ 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") {
from(shebang) {
// language=Shell Script
"""
|#### Note: this hook was autogenerated. You can edit it in settings.gradle.kts
|OLD_DIR=$(pwd)
|cd ${rootDir.absolutePath}
|GRADLEW=./gradlew
|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()
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()
// }
}
}

createHooks(overwriteExisting = true)
}*/
}