Skip to content

Commit 9862796

Browse files
committed
fix: remove getCheckRunsState
1 parent 9c65388 commit 9862796

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

pkg/repository/repository_state.go

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"strings"
87

98
"github.com/google/go-github/v41/github"
109
"github.com/rs/zerolog/log"
@@ -59,11 +58,11 @@ func (r *Repository) getAggregatedState(ctx context.Context, pr *github.PullRequ
5958
return "", err
6059
}
6160

62-
if status == Pending {
61+
if status == Pending || status == Success {
6362
return status, nil
6463
}
6564

66-
return r.getCheckRunsState(ctx, pr)
65+
return "", fmt.Errorf("PR status: %s", status)
6766
}
6867

6968
// getStatus provide checks status (status).
@@ -102,42 +101,3 @@ func (r *Repository) getStatus(ctx context.Context, pr *github.PullRequest) (str
102101

103102
return "", errors.New(summary)
104103
}
105-
106-
// getCheckRunsState provide checks status (checksRun).
107-
func (r *Repository) getCheckRunsState(ctx context.Context, pr *github.PullRequest) (string, error) {
108-
prRef := pr.Head.GetSHA()
109-
110-
checkSuites, _, err := r.client.Checks.ListCheckSuitesForRef(ctx, r.owner, r.name, prRef, nil)
111-
if err != nil {
112-
return "", err
113-
}
114-
115-
if checkSuites.GetTotal() == 0 {
116-
return Success, nil
117-
}
118-
119-
ignoredApps := []string{"dependabot", "renovate", "github-pages"}
120-
121-
var msg []string
122-
for _, v := range checkSuites.CheckSuites {
123-
slug := v.GetApp().GetSlug()
124-
125-
if contains(ignoredApps, slug) {
126-
continue
127-
}
128-
129-
if v.GetStatus() != "completed" {
130-
return Pending, nil
131-
}
132-
133-
if v.GetConclusion() != "success" && v.GetConclusion() != "neutral" {
134-
msg = append(msg, fmt.Sprintf("%s %s %s", v.GetApp().GetName(), v.GetStatus(), v.GetConclusion()))
135-
}
136-
}
137-
138-
if len(msg) == 0 {
139-
return Success, nil
140-
}
141-
142-
return "", errors.New(strings.Join(msg, ", "))
143-
}

0 commit comments

Comments
 (0)