diff --git a/kotlinova-gradle/src/main/kotlin/si/inova/kotlinova/gradle/detektprecommit/DetectPreCommitHook.kt b/kotlinova-gradle/src/main/kotlin/si/inova/kotlinova/gradle/detektprecommit/DetectPreCommitHook.kt index 9ad5e8e..a41abf4 100644 --- a/kotlinova-gradle/src/main/kotlin/si/inova/kotlinova/gradle/detektprecommit/DetectPreCommitHook.kt +++ b/kotlinova-gradle/src/main/kotlin/si/inova/kotlinova/gradle/detektprecommit/DetectPreCommitHook.kt @@ -29,14 +29,14 @@ internal fun Project.registerDetektPreCommitHook(extension: KotlinovaExtension) detektTask.usesService(serviceProvider) if (project.hasProperty("precommit")) { - val projectDir = projectDir - val fileCollection = files() + val originalSource = detektTask.source + detektTask.setSource( serviceProvider.flatMap { it.stagedGitFiles }.map { stagedFiles -> val stagedFilesFromThisProject = stagedFiles - .filter { it.startsWith(projectDir) } + .filter { originalSource.contains(it) } fileCollection.setFrom(*stagedFilesFromThisProject.toTypedArray())