Skip to content

Commit

Permalink
Updates last and export commands to read from correct key.
Browse files Browse the repository at this point in the history
Fixes #1155.

It seems that somehow during the 0.13.{1 -> 2 } transition, we
stopped pointing at the correct key for TaskKeys (either that or
task streams are now all associated with the `streams` key).  I
think this may have been inadvertently caused from several
refactorings to enable greater control over the execution of tasks.

This points the `last*` methods at the correct key for tasks,
fixing both `last <key>` and `export <key>` commands.
  • Loading branch information
jsuereth authored and eed3si9n committed Mar 21, 2014
1 parent 1fc2988 commit e899f95
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main/src/main/scala/sbt/Output.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object Output
def last(keys: Values[_], streams: Streams, printLines: Seq[String] => Unit)(implicit display: Show[ScopedKey[_]]): Unit =
last(keys, streams, printLines, None)(display)

def last(keys: Values[_], streams: Streams, printLines: Seq[String] => Unit, sid: Option[String])(implicit display: Show[ScopedKey[_]]): Unit =
def last(keys: Values[_], streams: Streams, printLines: Seq[String] => Unit, sid: Option[String])(implicit display: Show[ScopedKey[_]]): Unit =
printLines( flatLines(lastLines(keys, streams, sid))(idFun) )

def last(file: File, printLines: Seq[String] => Unit, tailDelim: String = DefaultTail): Unit =
Expand Down Expand Up @@ -55,7 +55,17 @@ object Output
@deprecated("Explicitly provide None for the stream ID.", "0.13.0")
def lastLines(key: ScopedKey[_], mgr: Streams): Seq[String] = lastLines(key, mgr, None)

def lastLines(key: ScopedKey[_], mgr: Streams, sid: Option[String]): Seq[String] = mgr.use(key) { s => IO.readLines(s.readText( Project.fillTaskAxis(key), sid )) }
def lastLines(key: ScopedKey[_], mgr: Streams, sid: Option[String]): Seq[String] =
mgr.use(key) { s =>
// Workaround for #1155 - Keys.streams are always scoped by the task they're included in
// but are keyed by the Keys.streams key. I think this isn't actually a workaround, but
// is how things are expected to work now.
// You can see where streams are injected using their own key scope in
// EvaluateTask.injectStreams.
val streamScopedKey: ScopedKey[_] = ScopedKey(Project.fillTaskAxis(key).scope, Keys.streams.key)
val tmp = s.readText( streamScopedKey, sid )
IO.readLines(tmp)
}

def tailLines(file: File, tailDelim: String): Seq[String] = headLines(IO.readLines(file).reverse, tailDelim).reverse

Expand Down

0 comments on commit e899f95

Please sign in to comment.