5import (
6 "context"
7▶ "errors"
8 "fmt"
9 "io"
· · ·
126// collected --depth commits. iter.ForEach surfaces whatever the callback
127// returns, so we can compare it back at the call site directly.
128▶var errStopIter = errors.New("history: stop iteration")
129
130// Bucketing divides [From, To] into N equal time slices. Used by the timeline
· · ·
202// (newest first → oldest first), and feeds every commit's first-parent diff
203// to the observer.
204▶func runHistory(repoPath string, observer CommitObserver) (HistoryWindow, error) {
205 // Turn GC back on because we have no idea how much we are about to process
206 EnableGc()
· · ·
208 repo, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true})
209 if err != nil {
210▶ return HistoryWindow{}, fmt.Errorf("open git repository: %w", err)
211 }
212
· · ·
213 head, err := repo.Head()
214 if err != nil {
215▶ if errors.Is(err, plumbing.ErrReferenceNotFound) {
216 observer.Finalise(HistoryWindow{}, emptySnapshot())
217 return HistoryWindow{}, nil
+ 15 more matches in this file