Skip to content

Commit 7a5bd6e

Browse files
committed
fix: copilot review
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
1 parent 1348cec commit 7a5bd6e

3 files changed

Lines changed: 2 additions & 24 deletions

File tree

codeowners.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ func (l *GithubReposPlugin) FetchCodeOwners(ctx context.Context, repo *github.Re
2626
continue
2727
}
2828
if isPermissionError(err) {
29-
l.Logger.Debug("CODEOWNERS fetch skipped due to permissions", "repo", repo.GetFullName(), "path", path, "error", err)
3029
return nil, nil
3130
}
3231
return nil, err
3332
}
3433
if file != nil {
35-
l.Logger.Debug("Found CODEOWNERS file", "repo", repo.GetFullName(), "path", path)
3634
return file, nil
3735
}
3836
}
3937

40-
l.Logger.Debug("No CODEOWNERS file found for repository", "repo", repo.GetFullName())
4138
return nil, nil
4239
}

main.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ package main
22

33
import (
44
"context"
5-
"encoding/json"
65
"errors"
76
"fmt"
8-
"os"
97
"slices"
108
"strings"
119

@@ -125,8 +123,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
125123
done = true
126124
continue
127125
}
128-
l.Logger.Debug("Processing repository:", "repo_name", repo.GetName())
129-
130126
workflows, err := l.GatherConfiguredWorkflows(ctx, repo)
131127
if err != nil {
132128
l.Logger.Error("Error gathering workflows", "error", err)
@@ -159,10 +155,8 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
159155
continue
160156
}
161157
name := b.GetName()
162-
l.Logger.Debug("Found protected branch", "branch", name)
163158
branchNames = append(branchNames, name)
164159
protection, checks, err := l.GetBranchProtectionAndRequiredStatusCheck(ctx, repo, name)
165-
l.Logger.Debug("Fetched branch protection info", "branch", name, "protection", protection, "checks", checks)
166160
if err != nil {
167161
l.Logger.Trace("Branch protection fetch failed", "repo", repo.GetFullName(), "branch", name, "error", err)
168162
continue
@@ -176,7 +170,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
176170
}
177171
// Fallback to default branch if none collected
178172
if len(requiredChecks) == 0 {
179-
l.Logger.Debug("No protected branches with required status checks found, checking default branch", "repo", repo.GetFullName())
180173
if def := repo.GetDefaultBranch(); def != "" {
181174
if protection, checks, err := l.GetBranchProtectionAndRequiredStatusCheck(ctx, repo, def); err == nil {
182175
if protection != nil {
@@ -243,13 +236,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
243236
// Uncomment to check the data that is being passed through from
244237
// the client, as data formats are often slightly different than
245238
// the raw API endpoints
246-
jsonData, _ := json.Marshal(data.OpenPullRequests)
247-
// l.Logger.Debug("Data", "data", string(jsonData))
248-
err = os.WriteFile(fmt.Sprintf("./dist/%s.json", repo.GetName()), jsonData, 0o644)
249-
if err != nil {
250-
l.Logger.Error("failed to write file", "error", err)
251-
}
252-
253239
evidences, err := l.EvaluatePolicies(ctx, data, req)
254240
if err != nil {
255241
l.Logger.Error("Error evaluating policies", "error", err)
@@ -265,7 +251,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
265251
}, err
266252
}
267253

268-
l.Logger.Debug("Successfully processed repository:", "repo_name", repo.GetName())
269254
}
270255
}
271256

@@ -325,7 +310,7 @@ func (l *GithubReposPlugin) FetchRepositories(ctx context.Context, req *proto.Ev
325310
repochan <- repo
326311
}
327312

328-
if resp.NextPage == 0 {
313+
if resp == nil || resp.NextPage == 0 {
329314
done = true
330315
} else {
331316
paginationOpts.Page = resp.NextPage
@@ -388,7 +373,7 @@ func (l *GithubReposPlugin) ListProtectedBranches(ctx context.Context, repo *git
388373
return nil, err
389374
}
390375
out = append(out, branches...)
391-
if resp.NextPage == 0 {
376+
if resp == nil || resp.NextPage == 0 {
392377
break
393378
}
394379
opts.Page = resp.NextPage

pull_requests.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"encoding/json"
65
"fmt"
76

87
"github.com/google/go-github/v71/github"
@@ -96,9 +95,6 @@ func (l *GithubReposPlugin) GatherReviewsAndComments(ctx context.Context, repo *
9695
l.Logger.Error("failed to fetch pull request review threads", "error", err)
9796
return ProcessOpenPullRequests(prs, reviewsByPR, nil), nil
9897
}
99-
l.Logger.Debug("fetched pull request review threads", "count", len(threadsByReview))
100-
threadsJson, _ := json.Marshal(threadsByReview)
101-
l.Logger.Debug("fetched pull request review threads", "threads", string(threadsJson))
10298

10399
return ProcessOpenPullRequests(prs, reviewsByPR, threadsByReview), nil
104100
}

0 commit comments

Comments
 (0)