( module Module, graph *dag.Graph[string, Module], remoteOnly bool, )
| 458 | } |
| 459 | |
| 460 | func moduleSetToDAGRec( |
| 461 | module Module, |
| 462 | graph *dag.Graph[string, Module], |
| 463 | remoteOnly bool, |
| 464 | ) error { |
| 465 | // If remoteOnly is set, then we only want to add remote modules as nodes. However, we do |
| 466 | // not want to return necessarily, because we want to capture all remote dependencies. |
| 467 | // |
| 468 | // We do not return early and ignore local modules entirely, because we still want to check |
| 469 | // for remote dependencies from local modules. |
| 470 | if !remoteOnly || !module.IsLocal() { |
| 471 | graph.AddNode(module) |
| 472 | } |
| 473 | directModuleDeps, err := ModuleDirectModuleDeps(module) |
| 474 | if err != nil { |
| 475 | return err |
| 476 | } |
| 477 | for _, directModuleDep := range directModuleDeps { |
| 478 | // If remoteOnly is set, then we only want to add the edge if both the module _and_ the |
| 479 | // dependency are remote. |
| 480 | if !remoteOnly || (!module.IsLocal() && !directModuleDep.IsLocal()) { |
| 481 | graph.AddEdge(module, directModuleDep) |
| 482 | } |
| 483 | // We still want to check all transitive dependencies for all modules. |
| 484 | if err := moduleSetToDAGRec(directModuleDep, graph, remoteOnly); err != nil { |
| 485 | return err |
| 486 | } |
| 487 | } |
| 488 | return nil |
| 489 | } |
| 490 | |
| 491 | func modulesOpaqueIDs(modules []Module) []string { |
| 492 | return xslices.Map( |
no test coverage detected
searching dependent graphs…