Merge pull request #4593 from eatkins/globlister-depth

Fix depth condition on GlobLister.aggregate
This commit is contained in:
eugene yokota 2019-03-31 13:33:32 -04:00 committed by GitHub
commit 5a65c63e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -74,8 +74,8 @@ private[internal] object GlobListers {
private def covers(left: Glob, right: Glob): Boolean = {
right.base.startsWith(left.base) && {
left.depth == Int.MaxValue || {
val depth = left.base.relativize(right.base).getNameCount
depth < left.depth - right.depth
val depth = left.base.relativize(right.base).getNameCount - 1
depth <= left.depth - right.depth
}
}
}

View File

@ -52,3 +52,20 @@ checkSet := {
val expected = Seq("Bar.md", "Foo.txt").map(baseDirectory.value / "base/subdir/nested-subdir" / _)
assert(deduped.sorted == expected)
}
val depth = taskKey[Seq[File]]("Specify redundant sources with limited depth")
val checkDepth = taskKey[Unit]("Check that the Bar.md file is retrieved")
depth / fileInputs ++= Seq(
sbt.io.Glob(baseDirectory.value / "base", -DirectoryFilter, 2),
sbt.io.Glob(baseDirectory.value / "base" / "subdir", -DirectoryFilter, 1)
)
checkDepth := {
val redundant = (depth / fileInputs).value.all.map(_._1.toFile)
assert(redundant.size == 2)
val deduped = (depth / fileInputs).value.toSet[Glob].all.map(_._1.toFile)
val expected = Seq("Bar.md", "Foo.txt").map(baseDirectory.value / "base/subdir/nested-subdir" / _)
assert(deduped.sorted == expected)
}

View File

@ -4,4 +4,6 @@
> checkAll
> checkSet
> checkSet
> checkDepth