@@ -135,8 +135,8 @@ tasks.register("allDependencies") {
135135 }
136136}
137137
138- fun getCommittedFilePaths (rootDir : File ): List <String > {
139- val filePaths = mutableListOf<String >()
138+ fun getCommittedFilePaths (rootDir : File ): List <File > {
139+ val filePaths = mutableListOf<File >()
140140
141141 Git .open(rootDir).use { git ->
142142 TreeWalk (git.repository).use { treeWalk ->
@@ -151,7 +151,7 @@ fun getCommittedFilePaths(rootDir: File): List<String> {
151151 }
152152
153153 while (treeWalk.next()) {
154- filePaths + = treeWalk.pathString
154+ filePaths + = rootDir.resolve( treeWalk.pathString)
155155 }
156156 }
157157 }
@@ -192,9 +192,7 @@ val copyrightExcludedExtensions = listOf(
192192)
193193
194194fun getCopyrightableFiles (rootDir : File ): List <File > =
195- getCommittedFilePaths(rootDir).map { filePath ->
196- rootDir.resolve(filePath)
197- }.filter { file ->
195+ getCommittedFilePaths(rootDir).filter { file ->
198196 val isHidden = file.toPath().any { it.toString().startsWith(" ." ) }
199197
200198 ! isHidden
@@ -350,10 +348,9 @@ val checkGitAttributes by tasks.registering {
350348 val gitAttributesFiles = files.filter { it.endsWith(" .gitattributes" ) }
351349 val commentChars = setOf (' #' , ' /' )
352350
353- gitAttributesFiles.forEach { gitAttributes ->
354- logger.lifecycle(" Checking file '$gitAttributes '..." )
351+ gitAttributesFiles.forEach { gitAttributesFile ->
352+ logger.lifecycle(" Checking file '$gitAttributesFile '..." )
355353
356- val gitAttributesFile = file(gitAttributes)
357354 val ignoreRules = gitAttributesFile.readLines()
358355 // Skip empty and comment lines.
359356 .map { it.trim() }
@@ -365,17 +362,17 @@ val checkGitAttributes by tasks.registering {
365362 runCatching {
366363 FastIgnoreRule (pattern)
367364 }.onFailure {
368- logger.warn(" File '$gitAttributes ' contains an invalid pattern in line ${index + 1 } : $it " )
365+ logger.warn(" File '$gitAttributesFile ' contains an invalid pattern in line ${index + 1 } : $it " )
369366 }.getOrNull()
370367 }
371368
372369 // Check only those files that are in scope of this ".gitattributes" file.
373370 val gitAttributesDir = gitAttributesFile.parentFile
374- val filesInScope = files.filter { rootDir.resolve(it) .startsWith(gitAttributesDir) }
371+ val filesInScope = files.filter { it .startsWith(gitAttributesDir) }
375372
376373 ignoreRules.forEach { rule ->
377374 val matchesAnything = filesInScope.any { file ->
378- val relativeFile = file(file) .relativeTo(gitAttributesDir)
375+ val relativeFile = file.relativeTo(gitAttributesDir)
379376 rule.isMatch(relativeFile.invariantSeparatorsPath, /* directory = */ false )
380377 }
381378
0 commit comments