Skip to content
Merged
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
27 changes: 26 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type SaturatedRepository struct {
// RequiredStatusChecks maps branch name -> required status checks configuration
RequiredStatusChecks map[string]*github.RequiredStatusChecks `json:"required_status_checks"`
SBOM *github.SBOM `json:"sbom"`
LastRelease *github.RepositoryRelease `json:"last_release"`
OpenPullRequests []*github.PullRequest `json:"pull_requests"`
}

Expand Down Expand Up @@ -175,13 +176,20 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
Status: proto.ExecutionStatus_FAILURE,
}, err
}

release, err := l.FecthLatestRelease(ctx, repo)
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in function name: 'Fecth' should be 'Fetch'.

Suggested change
release, err := l.FecthLatestRelease(ctx, repo)
release, err := l.FetchLatestRelease(ctx, repo)

Copilot uses AI. Check for mistakes.
if err != nil {
l.Logger.Error("error gathering latest release", "error", err)
return &proto.EvalResponse{
Status: proto.ExecutionStatus_FAILURE,
}, err
}
data := &SaturatedRepository{
Settings: repo,
Workflows: workflows,
WorkflowRuns: workflowRuns,
ProtectedBranches: branchNames,
RequiredStatusChecks: requiredChecks,
LastRelease: release,
SBOM: sbom,
OpenPullRequests: pullRequests,
}
Expand Down Expand Up @@ -282,6 +290,23 @@ func (l *GithubReposPlugin) FetchRepositories(ctx context.Context, req *proto.Ev
return repochan, errchan
}

func (l *GithubReposPlugin) FecthLatestRelease(ctx context.Context, repo *github.Repository) (*github.RepositoryRelease, error) {
owner := repo.GetOwner().GetLogin()
name := repo.GetName()

release, resp, err := l.githubClient.Repositories.GetLatestRelease(ctx, owner, name)
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function naming is inconsistent with similar functions in this file. Other similar functions use the "Gather" prefix (e.g., GatherSBOM, GatherOpenPullRequests, GatherWorkflowRuns). Consider renaming to GatherLatestRelease for consistency.

Suggested change
release, resp, err := l.githubClient.Repositories.GetLatestRelease(ctx, owner, name)
func (l *GithubReposPlugin) GatherLatestRelease(ctx context.Context, repo *github.Repository) (*github.RepositoryRelease, error) {

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in function name: 'Fecth' should be 'Fetch'.

Suggested change
release, resp, err := l.githubClient.Repositories.GetLatestRelease(ctx, owner, name)
func (l *GithubReposPlugin) FetchLatestRelease(ctx context.Context, repo *github.Repository) (*github.RepositoryRelease, error) {

Copilot uses AI. Check for mistakes.
if err != nil {
// If there is simply no release, GitHub returns 404. Treat this as "no release" rather than a hard error.
if resp != nil && resp.Response != nil && resp.StatusCode == 404 {
l.Logger.Trace("No releases found for repository", "repo", repo.GetFullName())
return nil, nil
}
return nil, err
}

return release, nil
}

func (l *GithubReposPlugin) GatherConfiguredWorkflows(ctx context.Context, repo *github.Repository) ([]*github.Workflow, error) {
workflows, _, err := l.githubClient.Actions.ListWorkflows(ctx, repo.GetOwner().GetLogin(), repo.GetName(), nil)
if err != nil {
Expand Down