Skip to content

Commit

Permalink
Merge pull request #57 from inovait/git-hook-nested-fix
Browse files Browse the repository at this point in the history
fix(gradle): pre-commit hook including nested projects
  • Loading branch information
matejdro authored Oct 15, 2024
2 parents baf0bd4 + d2c6c91 commit a6068e6
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit a6068e6

Please sign in to comment.