MCPcopy
hub / github.com/ossf/scorecard / ListCommits

Method ListCommits

clients/git/client.go:118–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116}
117
118func (c *Client) ListCommits() ([]clients.Commit, error) {
119 c.listCommits.Do(func() {
120 commitIter, err := c.gitRepo.Log(&git.LogOptions{
121 Order: git.LogOrderCommitterTime,
122 })
123 if err != nil {
124 c.errListCommits = fmt.Errorf("git.CommitObjects: %w", err)
125 return
126 }
127 c.commits = make([]clients.Commit, 0, c.commitDepth)
128 for i := 0; i < c.commitDepth; i++ {
129 commit, err := commitIter.Next()
130 if err != nil && !errors.Is(err, io.EOF) {
131 c.errListCommits = fmt.Errorf("commitIter.Next: %w", err)
132 return
133 }
134 // No more commits.
135 if errors.Is(err, io.EOF) {
136 break
137 }
138
139 if commit == nil {
140 // Not sure in what case a nil commit is returned. Fail explicitly.
141 c.errListCommits = fmt.Errorf("%w", errNilCommitFound)
142 return
143 }
144
145 c.commits = append(c.commits, clients.Commit{
146 SHA: commit.Hash.String(),
147 Message: commit.Message,
148 CommittedDate: commit.Committer.When,
149 Committer: clients.User{
150 Login: commit.Committer.Email,
151 },
152 })
153 }
154 })
155 return c.commits, c.errListCommits
156}
157
158func (c *Client) Search(request clients.SearchRequest) (clients.SearchResponse, error) {
159 // Pattern

Callers 1

TestListCommitsFunction · 0.95

Calls 2

NextMethod · 0.65
StringMethod · 0.65

Tested by 1

TestListCommitsFunction · 0.76