Skip to content

Commit 4efc1a1

Browse files
committed
Fix path separator for Windows in git hook generation
The gradleRootDirPrefix was using platform-specific path separators (backslash on Windows), but git hook scripts always require forward slashes. This caused tests to fail on Windows. Changed to always use forward slashes by replacing File.separator with "/" when constructing gradleRootDirPrefix. Fixes test failures on windows-latest CI runners.
1 parent 225f9e1 commit 4efc1a1

File tree

1 file changed

+1
-1
lines changed
  • plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint

1 file changed

+1
-1
lines changed

plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ open class KtlintInstallGitHookTask @Inject constructor(
190190
gitHookFile.createNewFile()
191191
gitHookFile.setExecutable(true)
192192
}
193-
val gradleRootDirPrefix = File(rootDirectory.get()).relativeTo(repo.workTree).path
193+
val gradleRootDirPrefix = File(rootDirectory.get()).relativeTo(repo.workTree).path.replace(File.separator, "/")
194194

195195
if (gitHookFile.length() == 0L) {
196196
gitHookFile.writeText(

0 commit comments

Comments
 (0)