mirror of https://github.com/sbt/sbt.git
Fix stackoverflow in implicit FilesInfo JsonFormat
Fixes #61 * move it back into style * use that in Tracked (uncomment some code) * specify the style in the spec test * must define absolute file.. (doesn't pass with relative, which is wrong imo)
This commit is contained in:
parent
1368f5f9db
commit
92e90c559b
|
|
@ -23,7 +23,6 @@ private final case class FileHashModified(file: File, hash: List[Byte], lastModi
|
|||
|
||||
final case class FilesInfo[F <: FileInfo] private (files: Set[F])
|
||||
object FilesInfo {
|
||||
implicit def format[F <: FileInfo]: JsonFormat[FilesInfo[F]] = implicitly
|
||||
def empty[F <: FileInfo]: FilesInfo[F] = FilesInfo(Set.empty[F])
|
||||
}
|
||||
|
||||
|
|
@ -32,6 +31,7 @@ object FileInfo {
|
|||
type F <: FileInfo
|
||||
|
||||
implicit def format: JsonFormat[F]
|
||||
implicit def formats: JsonFormat[FilesInfo[F]] = project(_.files, (fs: Set[F]) => FilesInfo(fs))
|
||||
|
||||
def apply(file: File): F
|
||||
def apply(files: Set[File]): FilesInfo[F] = FilesInfo(files map apply)
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import scala.json.ast.unsafe._
|
|||
import sjsonnew._, support.scalajson.unsafe._
|
||||
|
||||
class FileInfoSpec extends UnitSpec {
|
||||
val file = new java.io.File(".")
|
||||
val file = new java.io.File(".").getAbsoluteFile
|
||||
val fileInfo: ModifiedFileInfo = FileModified(file, file.lastModified())
|
||||
val filesInfo = FilesInfo(Set(fileInfo))
|
||||
|
||||
it should "round trip" in assertRoundTrip(filesInfo)
|
||||
it should "round trip" in assertRoundTrip(filesInfo)(FileInfo.lastModified.formats, FileInfo.lastModified.formats)
|
||||
|
||||
def assertRoundTrip[A: JsonWriter: JsonReader](x: A) = {
|
||||
val jsonString: String = toJsonString(x)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class Difference(val store: CacheStore, val style: FileInfo.Style, val defineCle
|
|||
}
|
||||
private def clearCache() = store.delete()
|
||||
|
||||
private def cachedFilesInfo = store.read(default = FilesInfo.empty[style.F]).files //(style.formats).files
|
||||
private def cachedFilesInfo = store.read(default = FilesInfo.empty[style.F])(style.formats).files
|
||||
private def raw(fs: Set[style.F]): Set[File] = fs.map(_.file)
|
||||
|
||||
def apply[T](files: Set[File])(f: ChangeReport[File] => T): T =
|
||||
|
|
@ -164,7 +164,7 @@ class Difference(val store: CacheStore, val style: FileInfo.Style, val defineCle
|
|||
val result = f(report)
|
||||
val info = if (filesAreOutputs) style(abs(extractFiles(result))) else currentFilesInfo
|
||||
|
||||
store.write(info)
|
||||
store.write(info)(style.formats)
|
||||
|
||||
result
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue