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

Function getRepoCommitHash

pkg/scorecard/scorecard.go:72–86  ·  view source on GitHub ↗
(r clients.RepoClient)

Source from the content-addressed store, hash-verified

70}
71
72func getRepoCommitHash(r clients.RepoClient) (string, error) {
73 commits, err := r.ListCommits()
74 if err != nil {
75 // allow --local repos to still process
76 if errors.Is(err, clients.ErrUnsupportedFeature) {
77 return "unknown", nil
78 }
79 return "", sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("ListCommits:%v", err.Error()))
80 }
81
82 if len(commits) == 0 {
83 return "", errEmptyRepository
84 }
85 return commits[0].SHA, nil
86}
87
88func runScorecard(ctx context.Context,
89 repo clients.Repo,

Callers 3

Test_getRepoCommitHashFunction · 0.85
runScorecardFunction · 0.85

Calls 3

WithMessageMethod · 0.80
ListCommitsMethod · 0.65
ErrorMethod · 0.45

Tested by 2

Test_getRepoCommitHashFunction · 0.68