mirror of https://github.com/sbt/sbt.git
Remove some heads and tails
This commit is contained in:
parent
d77e769635
commit
387674a451
|
|
@ -166,7 +166,7 @@ object State {
|
|||
/** Changes the maximum number of commands kept, adjusting the current history if necessary.*/
|
||||
def setMaxSize(size: Int): History =
|
||||
new History(if (size <= 0) executed else executed.take(size), size)
|
||||
def current: String = executed.head
|
||||
def currentOption: Option[String] = executed.headOption
|
||||
def previous: Option[String] = executed.drop(1).headOption
|
||||
}
|
||||
/** Constructs an empty command History with a default, finite command limit.*/
|
||||
|
|
|
|||
|
|
@ -41,12 +41,14 @@ final class StructureIndex(
|
|||
* The first root project is used as the default in several situations where a project is not otherwise selected.
|
||||
*/
|
||||
final class LoadedBuildUnit(val unit: BuildUnit, val defined: Map[String, ResolvedProject], val rootProjects: Seq[String], val buildSettings: Seq[Setting[_]]) extends BuildUnitBase {
|
||||
assert(rootProjects.nonEmpty, "No root projects defined for build unit " + unit)
|
||||
/**
|
||||
* The project to use as the default when one is not otherwise selected.
|
||||
* [[LocalRootProject]] resolves to this from within the same build.
|
||||
*/
|
||||
val root = rootProjects.head
|
||||
val root = rootProjects match {
|
||||
case Nil => throw new java.lang.AssertionError("assertion failed: No root projects defined for build unit " + unit)
|
||||
case Seq(root, _*) => root
|
||||
}
|
||||
|
||||
/** The base directory of the build unit (not the build definition).*/
|
||||
def localBase = unit.localBase
|
||||
|
|
|
|||
|
|
@ -312,7 +312,10 @@ private[sbt] object Load {
|
|||
def loaded(unit: BuildUnit): (PartBuildUnit, List[ProjectReference]) =
|
||||
{
|
||||
val defined = projects(unit)
|
||||
if (defined.isEmpty) sys.error("No projects defined in build unit " + unit)
|
||||
val firstDefined = defined match {
|
||||
case Nil => sys.error("No projects defined in build unit " + unit)
|
||||
case Seq(first, _*) => first
|
||||
}
|
||||
|
||||
// since base directories are resolved at this point (after 'projects'),
|
||||
// we can compare Files instead of converting to URIs
|
||||
|
|
@ -321,7 +324,7 @@ private[sbt] object Load {
|
|||
val externals = referenced(defined).toList
|
||||
val explicitRoots = unit.definitions.builds.flatMap(_.rootProject)
|
||||
val projectsInRoot = if (explicitRoots.isEmpty) defined.filter(isRoot) else explicitRoots
|
||||
val rootProjects = if (projectsInRoot.isEmpty) defined.head :: Nil else projectsInRoot
|
||||
val rootProjects = if (projectsInRoot.isEmpty) firstDefined :: Nil else projectsInRoot
|
||||
(new PartBuildUnit(unit, defined.map(d => (d.id, d)).toMap, rootProjects.map(_.id), buildSettings(unit)), externals)
|
||||
}
|
||||
def buildSettings(unit: BuildUnit): Seq[Setting[_]] =
|
||||
|
|
|
|||
|
|
@ -77,19 +77,21 @@ object Graph {
|
|||
}) +
|
||||
s.slice(at + 1, s.length)
|
||||
else s
|
||||
def toAsciiLines(node: A, level: Int): Vector[String] = {
|
||||
def toAsciiLines(node: A, level: Int): (String, Vector[String]) = {
|
||||
val line = limitLine((twoSpaces * level) + (if (level == 0) "" else "+-") + display(node))
|
||||
val cs = Vector(children(node): _*)
|
||||
val childLines = cs map { toAsciiLines(_, level + 1) }
|
||||
val withBar = childLines.zipWithIndex flatMap {
|
||||
case (lines, pos) if pos < (cs.size - 1) => lines map { insertBar(_, 2 * (level + 1)) }
|
||||
case (lines, pos) =>
|
||||
if (lines.last.trim != "") lines ++ Vector(twoSpaces * (level + 1))
|
||||
else lines
|
||||
case ((line, withBar), pos) if pos < (cs.size - 1) =>
|
||||
(line +: withBar) map { insertBar(_, 2 * (level + 1)) }
|
||||
case ((line, withBar), pos) if withBar.lastOption.getOrElse(line).trim != "" =>
|
||||
(line +: withBar) ++ Vector(twoSpaces * (level + 1))
|
||||
case ((line, withBar), _) => line +: withBar
|
||||
}
|
||||
line +: withBar
|
||||
(line, withBar)
|
||||
}
|
||||
|
||||
toAsciiLines(top, 0).mkString("\n")
|
||||
val (line, withBar) = toAsciiLines(top, 0)
|
||||
(line +: withBar).mkString("\n")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ object TestBuild {
|
|||
def inheritConfig(ref: ResolvedReference, config: ConfigKey) = projectFor(ref).confMap(config.name).extended map toConfigKey
|
||||
def inheritTask(task: AttributeKey[_]) = taskMap.get(task) match { case None => Nil; case Some(t) => t.delegates map getKey }
|
||||
def inheritProject(ref: ProjectRef) = project(ref).delegates
|
||||
def resolve(ref: Reference) = Scope.resolveReference(builds.head.uri, rootProject, ref)
|
||||
def resolve(ref: Reference) = Scope.resolveReference(root.uri, rootProject, ref)
|
||||
lazy val delegates: Scope => Seq[Scope] =
|
||||
Scope.delegates(
|
||||
allProjects,
|
||||
|
|
|
|||
Loading…
Reference in New Issue