(path string)
| 63 | } |
| 64 | |
| 65 | func (p *Project) DocFromIndex(path string) (*pb.Document, error) { |
| 66 | index, err := p.repo.Index() |
| 67 | if err != nil { |
| 68 | return nil, fmt.Errorf("could not retrieve index: %v", err) |
| 69 | } |
| 70 | |
| 71 | indexSize := int(index.EntryCount()) |
| 72 | for i := 0; i < indexSize; i++ { |
| 73 | entry, err := index.EntryByIndex(uint(i)) |
| 74 | if err != nil { |
| 75 | return nil, fmt.Errorf("failed to retrieve index entry: %v", err) |
| 76 | } |
| 77 | |
| 78 | if entry.Path == path { |
| 79 | doc, err := p.getDocument(entry.Id) |
| 80 | if err != nil { |
| 81 | return nil, fmt.Errorf("failed to read object from Git repository: %v", err) |
| 82 | } |
| 83 | return doc, nil |
| 84 | } |
| 85 | } |
| 86 | return nil, fmt.Errorf("could not find document with path '%s'", path) |
| 87 | } |
| 88 | |
| 89 | var ( |
| 90 | ErrNilObjectInfo = errors.New("an object's Info field cannot be nil") |
no test coverage detected