MCPcopy Index your code
hub / github.com/go-git/go-git / NewCommitAllIter

Function NewCommitAllIter

plumbing/object/commit_walker.go:196–235  ·  view source on GitHub ↗

NewCommitAllIter returns a new commit iterator for all refs. repoStorer is a repo Storer used to get commits and references. commitIterFunc is a commit iterator function, used to iterate through ref commits in chosen order

(repoStorer storage.Storer, commitIterFunc func(*Commit) CommitIter)

Source from the content-addressed store, hash-verified

194// repoStorer is a repo Storer used to get commits and references.
195// commitIterFunc is a commit iterator function, used to iterate through ref commits in chosen order
196func NewCommitAllIter(repoStorer storage.Storer, commitIterFunc func(*Commit) CommitIter) (CommitIter, error) {
197 commitsPath := list.New()
198 commitsLookup := make(map[plumbing.Hash]*list.Element)
199 head, err := storer.ResolveReference(repoStorer, plumbing.HEAD)
200 if err == nil {
201 err = addReference(repoStorer, commitIterFunc, head, commitsPath, commitsLookup)
202 }
203
204 if err != nil && err != plumbing.ErrReferenceNotFound {
205 return nil, err
206 }
207
208 // add all references along with the HEAD
209 refIter, err := repoStorer.IterReferences()
210 if err != nil {
211 return nil, err
212 }
213 defer refIter.Close()
214
215 for {
216 ref, err := refIter.Next()
217 if err == io.EOF {
218 break
219 }
220
221 if err == plumbing.ErrReferenceNotFound {
222 continue
223 }
224
225 if err != nil {
226 return nil, err
227 }
228
229 if err = addReference(repoStorer, commitIterFunc, ref, commitsPath, commitsLookup); err != nil {
230 return nil, err
231 }
232 }
233
234 return &commitAllIterator{commitsPath.Front()}, nil
235}
236
237func addReference(
238 repoStorer storage.Storer,

Callers 1

logAllMethod · 0.92

Calls 5

ResolveReferenceFunction · 0.92
addReferenceFunction · 0.85
IterReferencesMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…