From 1d467bd966b126f86c9c4359428cb1f0fb7cf2f7 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Wed, 12 Dec 2018 13:40:08 -0800 Subject: [PATCH] Fix FileRepository implementation for scripted I was seeing spurious travis failures and I finally tracked it down to the fact that in some cases, the project metabuild would sometimes use a caching file tree repository instead of a polling repository. This caused problems because the caching repository can take a few milliseconds to detect changes in a directory. Because scripted copies the project sources to the temporary test directory, it was possible for the project meta build compilation to be initiated before the cache was aware of all of the files. The reason this happened was because scripted would create a state where the remaining commands looked like: List(sbtPopOnFailure, resumeFromFailure, notifyUsersAboutShell, iflast shell, ~compile, < 41684) The ~compile command was causing the continuous flag to get set to true which caused the default file tree repository task to return the caching version. The reason for the continuous flag was so that when sbt is started in a non-interactive mode where the command is to be repeated, then we use the caching file tree repository. To support this use case, we just need to check that the last command begins with `~`, not that _any_ command begins with `~`. --- main/src/main/scala/sbt/internal/FileManagement.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/internal/FileManagement.scala b/main/src/main/scala/sbt/internal/FileManagement.scala index a18d3ef03..ec6eb2b8c 100644 --- a/main/src/main/scala/sbt/internal/FileManagement.scala +++ b/main/src/main/scala/sbt/internal/FileManagement.scala @@ -26,7 +26,7 @@ private[sbt] object FileManagement { val interactive = remaining.contains("shell") || remaining.lastOption.contains("iflast shell") val scripted = remaining.contains("setUpScripted") - val continuous = remaining.exists(_.startsWith(ContinuousExecutePrefix)) + val continuous = remaining.lastOption.exists(_.startsWith(ContinuousExecutePrefix)) if (!scripted && (interactive || continuous)) { FileTreeViewConfig .default(watchAntiEntropy.value, pollInterval.value, pollingDirectories.value)