Merge pull request #5873 from eatkins/supershell-batch-fix

Don't display progress in skip tasks in batch mode
This commit is contained in:
eugene yokota 2020-09-20 19:52:34 -04:00 committed by GitHub
commit 923ae57c1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 11 deletions

View File

@ -142,7 +142,7 @@ trait Terminal extends AutoCloseable {
private[sbt] def withRawOutput[R](f: => R): R
private[sbt] def restore(): Unit = {}
private[sbt] def progressState: ProgressState
private[this] val promptHolder: AtomicReference[Prompt] = new AtomicReference(Prompt.Pending)
private[this] val promptHolder: AtomicReference[Prompt] = new AtomicReference(Prompt.Batch)
private[sbt] final def prompt: Prompt = promptHolder.get
private[sbt] final def setPrompt(newPrompt: Prompt): Unit =
if (prompt != Prompt.NoPrompt) promptHolder.set(newPrompt)

View File

@ -1035,6 +1035,7 @@ object BuiltinCommands {
if (Terminal.startedByRemoteClient && !exchange.hasServer) {
Exec(Shutdown, None) +: s1
} else {
if (Terminal.console.prompt == Prompt.Batch) Terminal.console.setPrompt(Prompt.Pending)
exchange prompt ConsolePromptEvent(s0)
val minGCInterval = Project
.extract(s1)

View File

@ -106,7 +106,10 @@ private[sbt] class TaskProgress(
override def afterReady(task: Task[_]): Unit =
if (!closed.get) {
Util.ignoreResult(active.put(task, schedule(threshold, recurring = false)(doReport())))
if (skipReportTasks.contains(getShortName(task))) {
lastTaskCount.set(-1) // force a report for remote clients
report()
} else Util.ignoreResult(active.put(task, schedule(threshold, recurring = false)(doReport())))
} else {
logger.debug(s"called afterReady for ${taskName(task)} after task progress was closed")
}
@ -175,19 +178,23 @@ private[sbt] class TaskProgress(
}
}
private[this] def getShortName(task: Task[_]): String = {
val name = taskName(task)
name.lastIndexOf('/') match {
case -1 => name
case i =>
var j = i + 1
while (name(j) == ' ') j += 1
name.substring(j)
}
}
private[this] def filter(
tasks: Vector[(Task[_], Long)]
): (Vector[(Task[_], Long)], Boolean) = {
tasks.foldLeft((Vector.empty[(Task[_], Long)], false)) {
case ((tasks, skip), pair @ (t, _)) =>
val n = taskName(t)
val shortName = n.lastIndexOf('/') match {
case -1 => n
case i =>
var j = i + 1
while (n(j) == ' ') j += 1
n.substring(j)
}
val shortName = getShortName(t)
val newSkip = skip || skipReportTasks.contains(shortName)
if (hiddenTasks.contains(shortName)) (tasks, newSkip) else (tasks :+ pair, newSkip)
}

View File

@ -97,7 +97,7 @@ final class NetworkChannel(
case t => t.close()
}
interactive.set(value)
if (!isInteractive) terminal.setPrompt(Prompt.Batch)
if (isInteractive) terminal.setPrompt(Prompt.Pending)
attached.set(true)
pendingRequests.remove(id)
jsonRpcRespond("", id)