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

fix: break infinite recursion in renderTreeNode #33

Merged
merged 2 commits into from
Oct 17, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project/plugins/project/
.history
.cache
.lib/
.bsp

### Scala template
*.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
r <- graph.roots
d <- children(graph, r)
}
renderTreeNode(p, graph, d)
renderTreeNode(p, graph, d, Set.empty)
p.print("</pre></dd>").println()
}

private def renderTreeNode(p: Printer, graph: ModuleGraph, n: Module): Unit =
if (n.evictedByVersion.isEmpty) {
private def renderTreeNode(p: Printer, graph: ModuleGraph, n: Module, parents: Set[Module]): Unit =
// avoid cycles by checking if in parents
if (n.evictedByVersion.isEmpty && !parents.contains(n)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now fixed in a more proper way. This was also fixed in dependencyTree ascii rendering sbt/sbt-dependency-graph@0c3cf98

The reason is that grpc-core has a dependency to grpc-util, which has a compile scope dependency back to grpc-core https://repo1.maven.org/maven2/io/grpc/grpc-util/1.58.0/grpc-util-1.58.0.pom

Choose a reason for hiding this comment

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

Nice, that's better.

val moduleId = n.id
val name = moduleId.name
p.println()
Expand All @@ -99,7 +100,7 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
n.license.foreach(l => p.print(" ").print(l))
if (children(graph, n).nonEmpty) {
p.indent(4)
children(graph, n).foreach(renderTreeNode(p, graph, _))
children(graph, n).foreach(renderTreeNode(p, graph, _, parents + n))
p.indent(-4)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/sbt-test/dependencies/happy-path/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
enablePlugins(ParadoxPlugin)
paradoxTheme := None

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.17"
//libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.17"

libraryDependencies += "io.grpc" % "grpc-core" % "1.58.0"
Loading