MCPcopy
hub / github.com/redspread/spread / mapFromTree

Method mapFromTree

pkg/project/tree.go:11–38  ·  view source on GitHub ↗
(tree *git.Tree)

Source from the content-addressed store, hash-verified

9)
10
11func (p *Project) mapFromTree(tree *git.Tree) (docs map[string]*pb.Document, err error) {
12 var walkErr error
13 docs = make(map[string]*pb.Document, tree.EntryCount())
14 err = tree.Walk(func(path string, entry *git.TreeEntry) int {
15 // add objects to deployment
16 if entry.Type == git.ObjectBlob {
17 doc, err := p.getDocument(entry.Id)
18 if err != nil {
19 walkErr = err
20 return -1
21 }
22
23 path = path + entry.Name
24 docs[path] = doc
25 if walkErr != nil {
26 return -1
27 }
28 }
29 return 0
30 })
31
32 if err != nil {
33 err = fmt.Errorf("error starting walk: %v", err)
34 } else if walkErr != nil {
35 err = fmt.Errorf("error during walk: %v", walkErr)
36 }
37 return
38}

Callers 3

BranchMethod · 0.95
HeadMethod · 0.95
ResolveCommitMethod · 0.95

Calls 1

getDocumentMethod · 0.95

Tested by

no test coverage detected