Skip to content

Commit

Permalink
LicenseFilenamepatterns: De-duplicate the given patterns
Browse files Browse the repository at this point in the history
Before computing the license file globs out of it.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Oct 5, 2020
1 parent 8e57183 commit 2bfba27
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utils/src/main/kotlin/LicenseFilenamePatterns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ object LicenseFilenamePatterns {
directory: String,
filenamePatterns: Collection<String>
): List<String> {
val patternsForDir = filenamePatterns.map {
val distinctPatterns = filenamePatterns.toSet()

val patternsForDir = distinctPatterns.map {
getFileGlobForDirectory(File(directory).invariantSeparatorsPath, it, true)
}

val patternsForAncestorDirs = getAllAncestorDirectories(directory).flatMap { dir ->
filenamePatterns.map { getFileGlobForDirectory(dir, it, false) }
distinctPatterns.map { getFileGlobForDirectory(dir, it, false) }
}

return (patternsForDir + patternsForAncestorDirs).sorted()
Expand Down

0 comments on commit 2bfba27

Please sign in to comment.