GetCommitDataByIndex gets the commit node from the commit graph using index obtained from child node, if available
(i int)
| 37 | // GetCommitDataByIndex gets the commit node from the commit graph using index |
| 38 | // obtained from child node, if available |
| 39 | func (mi *MemoryIndex) GetCommitDataByIndex(i int) (*CommitData, error) { |
| 40 | if i >= len(mi.commitData) { |
| 41 | return nil, plumbing.ErrObjectNotFound |
| 42 | } |
| 43 | |
| 44 | commitData := mi.commitData[i] |
| 45 | |
| 46 | // Map parent hashes to parent indexes |
| 47 | if commitData.ParentIndexes == nil { |
| 48 | parentIndexes := make([]int, len(commitData.ParentHashes)) |
| 49 | for i, parentHash := range commitData.ParentHashes { |
| 50 | var err error |
| 51 | if parentIndexes[i], err = mi.GetIndexByHash(parentHash); err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | } |
| 55 | commitData.ParentIndexes = parentIndexes |
| 56 | } |
| 57 | |
| 58 | return commitData, nil |
| 59 | } |
| 60 | |
| 61 | // Hashes returns all the hashes that are available in the index |
| 62 | func (mi *MemoryIndex) Hashes() []plumbing.Hash { |
nothing calls this directly
no test coverage detected