MCPcopy Index your code
hub / github.com/redspread/spread / AddDocumentToIndex

Method AddDocumentToIndex

pkg/project/index.go:12–41  ·  view source on GitHub ↗
(doc *pb.Document)

Source from the content-addressed store, hash-verified

10)
11
12func (p *Project) AddDocumentToIndex(doc *pb.Document) error {
13 oid, size, err := p.createDocument(doc)
14 if err != nil {
15 return fmt.Errorf("object couldn't be created: %v", err)
16 }
17
18 info := doc.GetInfo()
19 if info == nil {
20 return ErrNilObjectInfo
21 }
22
23 entry := &git.IndexEntry{
24 Mode: git.FilemodeBlob,
25 Size: uint32(size),
26 Id: oid,
27 Path: info.Path,
28 }
29
30 index, err := p.repo.Index()
31 if err != nil {
32 return fmt.Errorf("could not retreive index: %v", err)
33 }
34
35 err = index.Add(entry)
36 if err != nil {
37 return err
38 }
39
40 return index.Write()
41}
42
43func (p *Project) Index() (docs map[string]*pb.Document, err error) {
44 index, err := p.repo.Index()

Callers 3

ParamMethod · 0.80
LinkMethod · 0.80
AddMethod · 0.80

Calls 5

createDocumentMethod · 0.95
GetInfoMethod · 0.80
IndexMethod · 0.80
WriteMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected