MCPcopy Create free account
hub / github.com/go-git/go-git / GetCommitDataByIndex

Method GetCommitDataByIndex

plumbing/format/commitgraph/v2/memory.go:51–71  ·  view source on GitHub ↗

GetCommitDataByIndex gets the commit node from the commit graph using index obtained from child node, if available

(i uint32)

Source from the content-addressed store, hash-verified

49// GetCommitDataByIndex gets the commit node from the commit graph using index
50// obtained from child node, if available
51func (mi *MemoryIndex) GetCommitDataByIndex(i uint32) (*CommitData, error) {
52 if i >= uint32(len(mi.commitData)) {
53 return nil, plumbing.ErrObjectNotFound
54 }
55
56 commitData := mi.commitData[i]
57
58 // Map parent hashes to parent indexes
59 if commitData.ParentIndexes == nil {
60 parentIndexes := make([]uint32, len(commitData.ParentHashes))
61 for i, parentHash := range commitData.ParentHashes {
62 var err error
63 if parentIndexes[i], err = mi.GetIndexByHash(parentHash); err != nil {
64 return nil, err
65 }
66 }
67 commitData.ParentIndexes = parentIndexes
68 }
69
70 return commitData.CommitData, nil
71}
72
73// Hashes returns all the hashes that are available in the index
74func (mi *MemoryIndex) Hashes() []plumbing.Hash {

Callers

nothing calls this directly

Calls 1

GetIndexByHashMethod · 0.95

Tested by

no test coverage detected