Skip to content

Commit

Permalink
limiting amount of commits to inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasSUSE committed Aug 12, 2024
1 parent a5c65af commit a3658ad
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"io"
"os"
"strings"
"time"
Expand Down Expand Up @@ -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
}

0 comments on commit a3658ad

Please sign in to comment.