Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid repeating versions in Eviction warning message #433

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ final class EvictionError private[sbt] (
out += "found version conflict(s) in library dependencies; some are suspected to be binary incompatible:"
out += ""
evictions.foreach({ case (a, scheme) =>
val revs = a.evicteds map { _.module.revision }
val revsStr =
if (revs.size <= 1) revs.mkString else "{" + revs.distinct.mkString(", ") + "}"
val seen: mutable.Set[ModuleID] = mutable.Set()
val callers: List[String] = (a.evicteds.toList ::: a.winner.toList) flatMap { r =>
val rev = r.module.revision
Expand All @@ -174,7 +171,7 @@ final class EvictionError private[sbt] (
}
val que = if (assumed) "?" else ""
val winnerRev = a.winner match {
case Some(r) => s":${r.module.revision} ($scheme$que) is selected over ${revsStr}"
case Some(r) => s":${r.module.revision} ($scheme$que) is selected over ${a.evictedRevs}"
case _ => " is evicted for all versions"
}
val title = s"\t* ${a.organization}:${a.name}$winnerRev"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ final class EvictionPair private[sbt] (
val includesDirect: Boolean,
val showCallers: Boolean
) {
val evictedRevs: String = {
val revs = evicteds map { _.module.revision }
if (revs.size <= 1) revs.mkString else revs.distinct.mkString("{", ", ", "}")
}

override def toString: String =
EvictionPair.evictionPairLines.showLines(this).mkString
override def equals(o: Any): Boolean = o match {
Expand All @@ -209,8 +214,6 @@ final class EvictionPair private[sbt] (

object EvictionPair {
implicit val evictionPairLines: ShowLines[EvictionPair] = ShowLines { (a: EvictionPair) =>
val revs = a.evicteds map { _.module.revision }
val revsStr = if (revs.size <= 1) revs.mkString else "{" + revs.mkString(", ") + "}"
val seen: mutable.Set[ModuleID] = mutable.Set()
val callers: List[String] = (a.evicteds.toList ::: a.winner.toList) flatMap { r =>
val rev = r.module.revision
Expand All @@ -223,7 +226,7 @@ object EvictionPair {
}
}
val winnerRev = a.winner match {
case Some(r) => s":${r.module.revision} is selected over ${revsStr}"
case Some(r) => s":${r.module.revision} is selected over ${a.evictedRevs}"
case _ => " is evicted for all versions"
}
val title = s"\t* ${a.organization}:${a.name}$winnerRev"
Expand Down