Documentation
¶
Index ¶
- func GetRateLimitRemaining(resp *http.Response) int
- func IsRateLimitError(err error) bool
- func IsRateLimitResponse(resp *http.Response) bool
- func TestsPassed(checkRuns []model.CheckRun) bool
- type Collector
- type GitHubCollector
- func (c *GitHubCollector) AnalyzePRForGoMod(ctx context.Context, repo model.RepoRef, prNumber int) (*GoModAnalysis, error)
- func (c *GitHubCollector) CreatePRComment(ctx context.Context, repo model.RepoRef, prNumber int, body string) (*PRComment, error)
- func (c *GitHubCollector) FindBotCommentByMarker(ctx context.Context, repo model.RepoRef, prNumber int, marker string) (*PRComment, error)
- func (c *GitHubCollector) GetLatestRelease(ctx context.Context, repo model.RepoRef) (*model.Release, error)
- func (c *GitHubCollector) GetMergedPRsSinceTag(ctx context.Context, repo model.RepoRef, tagName string) ([]model.PullRequest, error)
- func (c *GitHubCollector) GetPRChecks(ctx context.Context, repo model.RepoRef, prNumber int) ([]model.CheckRun, error)
- func (c *GitHubCollector) GetPRDetails(ctx context.Context, repo model.RepoRef, prNumber int) (*model.PullRequest, error)
- func (c *GitHubCollector) GetPRDiff(ctx context.Context, repo model.RepoRef, prNumber int) (string, error)
- func (c *GitHubCollector) GetPRFiles(ctx context.Context, repo model.RepoRef, prNumber int) ([]string, error)
- func (c *GitHubCollector) ListDependencyPRs(ctx context.Context, repo model.RepoRef) ([]model.PullRequest, error)
- func (c *GitHubCollector) ListRepos(ctx context.Context, orgs []string, filter model.RepoFilter) ([]model.Repo, error)
- func (c *GitHubCollector) ListTags(ctx context.Context, repo model.RepoRef) ([]model.Tag, error)
- func (c *GitHubCollector) UpdatePRComment(ctx context.Context, repo model.RepoRef, commentID int64, body string) (*PRComment, error)
- func (c *GitHubCollector) WaitForChecks(ctx context.Context, repo model.RepoRef, prNumber int, timeout time.Duration) ([]model.CheckRun, error)
- type GoModAnalysis
- type PRComment
- type RateLimitConfig
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRateLimitRemaining ¶ added in v0.4.0
GetRateLimitRemaining returns the remaining rate limit from a response.
func IsRateLimitError ¶ added in v0.4.0
IsRateLimitError checks if an error is a GitHub rate limit error.
func IsRateLimitResponse ¶ added in v0.4.0
IsRateLimitResponse checks if a response indicates rate limiting.
func TestsPassed ¶
TestsPassed checks if all check runs passed.
Types ¶
type Collector ¶
type Collector interface {
// ListRepos returns repositories matching the filter criteria.
ListRepos(ctx context.Context, orgs []string, filter model.RepoFilter) ([]model.Repo, error)
// ListDependencyPRs returns open dependency PRs for a repository.
ListDependencyPRs(ctx context.Context, repo model.RepoRef) ([]model.PullRequest, error)
// GetPRDetails returns detailed information about a specific PR.
GetPRDetails(ctx context.Context, repo model.RepoRef, prNumber int) (*model.PullRequest, error)
// GetPRChecks returns the CI check runs for a PR.
GetPRChecks(ctx context.Context, repo model.RepoRef, prNumber int) ([]model.CheckRun, error)
// GetLatestRelease returns the most recent release for a repository.
GetLatestRelease(ctx context.Context, repo model.RepoRef) (*model.Release, error)
// ListTags returns all tags for a repository.
ListTags(ctx context.Context, repo model.RepoRef) ([]model.Tag, error)
// GetMergedPRsSinceTag returns PRs merged since the given tag.
GetMergedPRsSinceTag(ctx context.Context, repo model.RepoRef, tagName string) ([]model.PullRequest, error)
}
Collector defines the interface for collecting repository and PR information.
type GitHubCollector ¶
type GitHubCollector struct {
// contains filtered or unexported fields
}
GitHubCollector implements Collector for GitHub repositories.
func NewGitHubCollector ¶
func NewGitHubCollector(token string) (*GitHubCollector, error)
NewGitHubCollector creates a new GitHub collector.
func (*GitHubCollector) AnalyzePRForGoMod ¶ added in v0.4.0
func (c *GitHubCollector) AnalyzePRForGoMod(ctx context.Context, repo model.RepoRef, prNumber int) (*GoModAnalysis, error)
AnalyzePRForGoMod analyzes a PR to determine if it's a safe Go dependency update.
func (*GitHubCollector) CreatePRComment ¶ added in v0.4.0
func (c *GitHubCollector) CreatePRComment(ctx context.Context, repo model.RepoRef, prNumber int, body string) (*PRComment, error)
CreatePRComment creates a new comment on a pull request.
func (*GitHubCollector) FindBotCommentByMarker ¶ added in v0.4.0
func (c *GitHubCollector) FindBotCommentByMarker(ctx context.Context, repo model.RepoRef, prNumber int, marker string) (*PRComment, error)
FindBotCommentByMarker finds an existing comment containing a specific marker. This is used to find comments created by the bot for updating.
func (*GitHubCollector) GetLatestRelease ¶
func (c *GitHubCollector) GetLatestRelease(ctx context.Context, repo model.RepoRef) (*model.Release, error)
GetLatestRelease returns the most recent release for a repository.
func (*GitHubCollector) GetMergedPRsSinceTag ¶
func (c *GitHubCollector) GetMergedPRsSinceTag(ctx context.Context, repo model.RepoRef, tagName string) ([]model.PullRequest, error)
GetMergedPRsSinceTag returns PRs merged since the given tag.
Note: unlike go-github's raw pagination, clientv1.ListPullRequests always fetches every matching PR before returning (it has no early-exit hook), so this can make more API calls than strictly necessary for repos with a very long closed-PR history. Results are still filtered correctly by since.
func (*GitHubCollector) GetPRChecks ¶
func (c *GitHubCollector) GetPRChecks(ctx context.Context, repo model.RepoRef, prNumber int) ([]model.CheckRun, error)
GetPRChecks returns the CI check runs for a PR.
func (*GitHubCollector) GetPRDetails ¶
func (c *GitHubCollector) GetPRDetails(ctx context.Context, repo model.RepoRef, prNumber int) (*model.PullRequest, error)
GetPRDetails returns detailed information about a specific PR.
func (*GitHubCollector) GetPRDiff ¶ added in v0.4.0
func (c *GitHubCollector) GetPRDiff(ctx context.Context, repo model.RepoRef, prNumber int) (string, error)
GetPRDiff returns the unified diff for a PR.
func (*GitHubCollector) GetPRFiles ¶ added in v0.4.0
func (c *GitHubCollector) GetPRFiles(ctx context.Context, repo model.RepoRef, prNumber int) ([]string, error)
GetPRFiles returns the list of files changed in a PR.
func (*GitHubCollector) ListDependencyPRs ¶
func (c *GitHubCollector) ListDependencyPRs(ctx context.Context, repo model.RepoRef) ([]model.PullRequest, error)
ListDependencyPRs returns open dependency PRs for a repository.
func (*GitHubCollector) ListRepos ¶
func (c *GitHubCollector) ListRepos(ctx context.Context, orgs []string, filter model.RepoFilter) ([]model.Repo, error)
ListRepos returns repositories matching the filter criteria.
type GoModAnalysis ¶ added in v0.4.0
type GoModAnalysis struct {
// Files changed
ChangedFiles []string
OnlyGoModFiles bool
// Directive changes detected in the diff
HasReplaceChange bool
HasExcludeChange bool
HasRetractChange bool
HasToolchainChange bool
HasGoVersionChange bool
HasDirectiveChanges bool
// Dependency changes
HasNewDirectDependency bool
NewDirectDependencies []string
RemovedDependencies []string
// Version info
OldGoVersion string
NewGoVersion string
}
GoModAnalysis contains the results of analyzing go.mod changes in a PR.
func (*GoModAnalysis) ToGoModContext ¶ added in v0.4.0
func (a *GoModAnalysis) ToGoModContext() model.GoModContext
ToGoModContext converts GoModAnalysis to model.GoModContext.
func (*GoModAnalysis) ToPRContextFields ¶ added in v0.4.0
func (a *GoModAnalysis) ToPRContextFields() (changedFiles []string, onlyGoModFiles bool, changedFileExts []string)
ToPRContextFields returns fields to update in PRContext.
type PRComment ¶ added in v0.4.0
type PRComment struct {
ID int64
Body string
Author string
CreatedAt time.Time
UpdatedAt time.Time
}
PRComment represents a comment on a pull request.
type RateLimitConfig ¶ added in v0.4.0
type RateLimitConfig struct {
// MinRemaining is the minimum remaining requests before pausing.
// When rate limit remaining falls below this, we wait until reset.
MinRemaining int
// MaxRetries is the maximum number of retries for rate-limited requests.
MaxRetries int
// BaseBackoff is the base duration for exponential backoff.
BaseBackoff time.Duration
// MaxBackoff is the maximum backoff duration.
MaxBackoff time.Duration
// Logger for rate limit warnings (optional).
Logger *slog.Logger
}
RateLimitConfig configures rate limit handling behavior.
func DefaultRateLimitConfig ¶ added in v0.4.0
func DefaultRateLimitConfig() RateLimitConfig
DefaultRateLimitConfig returns sensible default rate limit configuration.
type RateLimiter ¶ added in v0.4.0
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter handles GitHub API rate limiting with exponential backoff.
func NewRateLimiter ¶ added in v0.4.0
func NewRateLimiter(config RateLimitConfig) *RateLimiter
NewRateLimiter creates a new rate limiter with the given configuration.
func (*RateLimiter) CheckRateLimit ¶ added in v0.4.0
CheckRateLimit checks the current rate limit status and waits if necessary. Returns an error if the context is cancelled while waiting.
func (*RateLimiter) HandleRateLimitError ¶ added in v0.4.0
func (rl *RateLimiter) HandleRateLimitError(ctx context.Context, resp *http.Response, attempt int) (bool, error)
HandleRateLimitError handles a rate limit error response. It waits for the appropriate duration before retrying. Returns true if the request should be retried, false otherwise.