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

Improve resolution comment #380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -336,7 +336,7 @@ private def cleanUpMap(
(
Graph[MavenCoordinate, Unit],
SortedMap[MavenCoordinate, ResolvedShasValue],
Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Unit]]]
Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Boolean]]]
)
] = {
def replaced(m: MavenCoordinate): Boolean =
Expand Down
5 changes: 3 additions & 2 deletions src/scala/com/github/johnynek/bazel_deps/MakeDeps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ object MakeDeps {
(
Graph[MavenCoordinate, Unit],
SortedMap[MavenCoordinate, ResolvedShasValue],
Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Unit]]]
Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Boolean]]]
)
] =
model.getOptions.getResolverType match {
Expand Down Expand Up @@ -259,7 +259,8 @@ object MakeDeps {
ns.flatMap { n =>
graph
.hasDestination(n)
.filter(e => normalized.nodes(e.source))
// label means whether it is evicted or not
.map(e => e.copy(label = !normalized.nodes(e.source)))
}
}
.filter { case (_, set) =>
Expand Down
2 changes: 1 addition & 1 deletion src/scala/com/github/johnynek/bazel_deps/Resolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Resolver {
type Result = (
Graph[MavenCoordinate, Unit],
SortedMap[MavenCoordinate, ResolvedShasValue],
Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Unit]]]
Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Boolean]]]
)
}

Expand Down
9 changes: 5 additions & 4 deletions src/scala/com/github/johnynek/bazel_deps/Writer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ object Writer {
}

def workspace(depsFile: String, g: Graph[MavenCoordinate, Unit],
duplicates: Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Unit]]],
duplicates: Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Boolean]]],
shas: Map[MavenCoordinate, ResolvedShasValue],
model: Model): String = {
val nodes = g.nodes
Expand Down Expand Up @@ -334,7 +334,7 @@ object Writer {
private def concreteToArtifactEntry(
coord: MavenCoordinate,
g: Graph[MavenCoordinate, Unit],
duplicates: Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Unit]]],
duplicates: Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Boolean]]],
shas: Map[MavenCoordinate, ResolvedShasValue],
model: Model
): ArtifactEntry = {
Expand Down Expand Up @@ -376,7 +376,8 @@ object Writer {
s"""# duplicates in ${coord.unversioned.asString} $status\n""" +
vs.filterNot(e => replaced(e.source))
.map { e =>
s"""# - ${e.source.asString} wanted version ${e.destination.version.asString}\n"""
val evicted = if (e.label) " (evicted)" else ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than using Boolean can we add to DepsModel.scala something like:

sealed abstract class EvictionState(val isEvicted: Boolean)
object EvictionState {
  case object Evicted extends EvictionState(true)
  case object Retained extends EvictionState(false)
}

so we don't have "boolean blindess" type bugs? I'd rather have Edge[MavenCoordinate, EvictionState]] and e.label.isEvicted

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I thought about that as well, it'd be much better!

However, I'm still concerned that with this fix we're just fixing a side effect of a different normalizer bug, see my latest comment on #379. We could continue the conversation there and if we find that this is indeed the right fix, and not something else, then I'll do the fix you recommended and we can merge, but first it'd be great to make sure. Thanks!

s"""# - ${e.source.asString}${evicted} wanted version ${e.destination.version.asString}\n"""
}
.toSeq
.sorted
Expand Down Expand Up @@ -405,7 +406,7 @@ object Writer {

def artifactEntries(
g: Graph[MavenCoordinate, Unit],
duplicates: Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Unit]]],
duplicates: Map[UnversionedCoordinate, Set[Edge[MavenCoordinate, Boolean]]],
shas: Map[MavenCoordinate, ResolvedShasValue],
model: Model
): Either[NonEmptyList[TargetsError], List[ArtifactEntry]] = {
Expand Down