From a3658ada61fcc9f62a94a97bfaf355046ae3b8ab Mon Sep 17 00:00:00 2001 From: nicholasSSUSE Date: Mon, 12 Aug 2024 18:58:38 -0300 Subject: [PATCH] limiting amount of commits to inspect --- repository/repository.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/repository/repository.go b/repository/repository.go index e3974f09..b952e658 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "io" "os" "strings" "time" @@ -624,10 +625,20 @@ func getCommits(r *git.Repository, h plumbing.Hash) ([]*object.Commit, error) { iter = object.NewCommitPreorderIter(firstCommit, nil, nil) + limit := 100 + count := 0 err = iter.ForEach(func(c *object.Commit) error { + if count >= limit { + return io.EOF + } commits = append(commits, c) + count++ return nil }) + if err == io.EOF { + err = nil // Reset error if it was forced by the limit + } + return commits, err }