Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Shearin <[email protected]>
  • Loading branch information
ashearin committed Dec 12, 2023
1 parent 1a1079e commit 1f445fb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clients/gitlabrepo/checkruns.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/ossf/scorecard/v4/clients"
)

var gitCommitHashRegex = regexp.MustCompile(`^[a-fA-F0-9]{40}$`)

type checkrunsHandler struct {
glClient *gitlab.Client
repourl *repoURL
Expand All @@ -33,13 +35,10 @@ func (handler *checkrunsHandler) init(repourl *repoURL) {
}

func (handler *checkrunsHandler) listCheckRunsForRef(ref string) ([]clients.CheckRun, error) {
commit := regexp.MustCompile("^[a-f0-9]{40}$")
options := gitlab.ListProjectPipelinesOptions{
ListOptions: gitlab.ListOptions{},
}
var options gitlab.ListProjectPipelinesOptions

// In Gitlab: ref refers to a branch or tag name, and sha refers to commit sha
if commit.MatchString(ref) {
if gitCommitHashRegex.MatchString(ref) {
options.SHA = &ref
} else {
options.Ref = &ref
Expand Down

0 comments on commit 1f445fb

Please sign in to comment.