MCPcopy Create free account
hub / github.com/bufbuild/buf / moduleSetToDAGRec

Function moduleSetToDAGRec

private/bufpkg/bufmodule/module_set.go:460–489  ·  view source on GitHub ↗
(
	module Module,
	graph *dag.Graph[string, Module],
	remoteOnly bool,
)

Source from the content-addressed store, hash-verified

458}
459
460func 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
491func modulesOpaqueIDs(modules []Module) []string {
492 return xslices.Map(

Callers 1

ModuleSetToDAGFunction · 0.85

Calls 4

ModuleDirectModuleDepsFunction · 0.85
IsLocalMethod · 0.65
AddNodeMethod · 0.45
AddEdgeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…