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

Method GetCommitDataByIndex

plumbing/format/commitgraph/memory.go:39–59  ·  view source on GitHub ↗

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

(i int)

Source from the content-addressed store, hash-verified

37// GetCommitDataByIndex gets the commit node from the commit graph using index
38// obtained from child node, if available
39func (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
62func (mi *MemoryIndex) Hashes() []plumbing.Hash {

Callers

nothing calls this directly

Calls 1

GetIndexByHashMethod · 0.95

Tested by

no test coverage detected