Skip to content

Commit

Permalink
Merge pull request #433 from rtyley/avoid-repeating-version-in-evicti…
Browse files Browse the repository at this point in the history
…on-warning

Avoid repeating versions in Eviction warning message
  • Loading branch information
eed3si9n committed Sep 18, 2023
2 parents a363771 + fdb519b commit aa090bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit aa090bd

Please sign in to comment.