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

Function remoteDepsForModuleSetRec

private/bufpkg/bufmodule/remote_dep.go:134–171  ·  view source on GitHub ↗
(
	remoteModule Module,
	visitedOpaqueIDs map[string]struct{},
)

Source from the content-addressed store, hash-verified

132func (*remoteDep) isRemoteDep() {}
133
134func remoteDepsForModuleSetRec(
135 remoteModule Module,
136 visitedOpaqueIDs map[string]struct{},
137) ([]Module, error) {
138 if remoteModule.IsLocal() {
139 return nil, syserror.New("only pass remote modules to remoteDepsForModuleSetRec")
140 }
141 if remoteModule.FullName() == nil {
142 // Just a sanity check.
143 return nil, syserror.New("FullName is nil for a remote Module")
144 }
145 opaqueID := remoteModule.OpaqueID()
146 if _, ok := visitedOpaqueIDs[opaqueID]; ok {
147 return nil, nil
148 }
149 visitedOpaqueIDs[opaqueID] = struct{}{}
150 recModuleDeps, err := remoteModule.ModuleDeps()
151 if err != nil {
152 return nil, err
153 }
154 recDeps := make([]Module, 0, len(recModuleDeps)+1)
155 recDeps = append(recDeps, remoteModule)
156 for _, recModuleDep := range recModuleDeps {
157 if recModuleDep.IsLocal() {
158 continue
159 }
160 // We deal with local vs remote in the recursive call.
161 iRecDeps, err := remoteDepsForModuleSetRec(
162 recModuleDep,
163 visitedOpaqueIDs,
164 )
165 if err != nil {
166 return nil, err
167 }
168 recDeps = append(recDeps, iRecDeps...)
169 }
170 return recDeps, nil
171}

Callers 1

RemoteDepsForModulesFunction · 0.85

Calls 5

NewFunction · 0.92
IsLocalMethod · 0.65
FullNameMethod · 0.65
OpaqueIDMethod · 0.65
ModuleDepsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…