Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Dependency-Update-Tool: ignore search commit data for repo clients which dont support it #3756

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions checks/dependency_update_tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,21 @@ func TestDependencyUpdateTool(t *testing.T) {
})
}
}

func TestDependencyUpdateTool_noSearchCommits(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
mockRepo := mockrepo.NewMockRepoClient(ctrl)
files := []string{"README.md"}
mockRepo.EXPECT().ListFiles(gomock.Any()).Return(files, nil)
mockRepo.EXPECT().SearchCommits(gomock.Any()).Return(nil, clients.ErrUnsupportedFeature)
dl := scut.TestDetailLogger{}
c := &checker.CheckRequest{
RepoClient: mockRepo,
Dlogger: &dl,
}
got := DependencyUpdateTool(c)
if got.Error != nil {
t.Errorf("got: %v, wanted ErrUnsupportedFeature not to propagate", got.Error)
}
}
9 changes: 8 additions & 1 deletion checks/raw/dependency_update_tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package raw

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -42,7 +43,13 @@

commits, err := c.SearchCommits(clients.SearchCommitsOptions{Author: "dependabot[bot]"})
if err != nil {
return checker.DependencyUpdateToolData{}, fmt.Errorf("%w", err)
// TODO https://github.com/ossf/scorecard/issues/1709
// some repo clients (e.g. local) don't currently have the ability to search commits,
// but some data is better than none.
if errors.Is(err, clients.ErrUnsupportedFeature) {
return checker.DependencyUpdateToolData{Tools: tools}, nil
}
return checker.DependencyUpdateToolData{}, fmt.Errorf("dependabot commit search: %w", err)

Check warning on line 52 in checks/raw/dependency_update_tool.go

View check run for this annotation

Codecov / codecov/patch

checks/raw/dependency_update_tool.go#L52

Added line #L52 was not covered by tests
}

for i := range commits {
Expand Down
Loading