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

Function ModuleSetToDAG

private/bufpkg/bufmodule/module_set.go:219–231  ·  view source on GitHub ↗

ModuleSetToDAG gets a DAG of the given ModuleSet. This only starts at target Modules. If a Module is not part of a graph with a target Module as a source, it will not be added.

(moduleSet ModuleSet, options ...ModuleSetToDAGOption)

Source from the content-addressed store, hash-verified

217// This only starts at target Modules. If a Module is not part of a graph
218// with a target Module as a source, it will not be added.
219func ModuleSetToDAG(moduleSet ModuleSet, options ...ModuleSetToDAGOption) (*dag.Graph[string, Module], error) {
220 moduleSetToDAGOptions := newModuleSetToDAGOptions()
221 for _, option := range options {
222 option(moduleSetToDAGOptions)
223 }
224 graph := dag.NewGraph[string, Module](Module.OpaqueID)
225 for _, module := range ModuleSetTargetModules(moduleSet) {
226 if err := moduleSetToDAGRec(module, graph, moduleSetToDAGOptions.remoteOnly); err != nil {
227 return nil, err
228 }
229 }
230 return graph, nil
231}
232
233// ModuleSetToDAGOption is an option for ModuleSetToDAG.
234type ModuleSetToDAGOption func(*moduleSetToDAGOptions)

Callers 3

runFunction · 0.92
TestBasicFunction · 0.92
testBasicFunction · 0.92

Calls 4

newModuleSetToDAGOptionsFunction · 0.85
optionStruct · 0.85
ModuleSetTargetModulesFunction · 0.85
moduleSetToDAGRecFunction · 0.85

Tested by 2

TestBasicFunction · 0.74
testBasicFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…