Documentation
¶
Index ¶
- Variables
- func GetLatestRelease(owner string, repo string) (string, error)
- func GetLatestReleaseInfo(owner, repo string) (*github.RepositoryRelease, error)
- func GetReleaseByTag(owner, repo, tag string) (*github.RepositoryRelease, error)
- func GetReleases(opts ReleasesOptions) ([]*github.RepositoryRelease, error)
- func ShouldWaitForRateLimit(ctx context.Context, minRemaining int) bool
- func ShouldWaitForRateLimitWithService(ctx context.Context, service RateLimitService, minRemaining int) bool
- func WaitForRateLimit(ctx context.Context, minRemaining int) error
- type RateLimitService
- type RateLimitStatus
- type ReleasesOptions
Constants ¶
This section is empty.
Variables ¶
var RateLimitWaiter = waitForRateLimitImpl
RateLimitWaiter is the function used to wait for rate limits. Tests can override this to skip the actual wait.
Functions ¶
func GetLatestRelease ¶
GetLatestRelease returns the latest release tag for a GitHub repository.
func GetLatestReleaseInfo ¶
func GetLatestReleaseInfo(owner, repo string) (*github.RepositoryRelease, error)
GetLatestReleaseInfo fetches the latest stable release from GitHub.
func GetReleaseByTag ¶
func GetReleaseByTag(owner, repo, tag string) (*github.RepositoryRelease, error)
GetReleaseByTag fetches a specific GitHub release by tag name.
func GetReleases ¶
func GetReleases(opts ReleasesOptions) ([]*github.RepositoryRelease, error)
GetReleases fetches GitHub releases with pagination, prerelease filtering, and date filtering.
func ShouldWaitForRateLimit ¶
ShouldWaitForRateLimit checks if rate limit is low enough to warrant waiting. This is a non-blocking check that just returns the decision.
func ShouldWaitForRateLimitWithService ¶
func ShouldWaitForRateLimitWithService(ctx context.Context, service RateLimitService, minRemaining int) bool
ShouldWaitForRateLimitWithService checks if rate limit is low using a custom service. This is primarily used for testing with mock services.
func WaitForRateLimit ¶
WaitForRateLimit checks GitHub rate limits and waits if necessary. If remaining requests are below minRemaining, it waits until the rate limit resets. Uses a spinner UI in TTY mode, otherwise simple output. Returns nil on success or context cancellation error. Does not return error on rate limit check failures (to avoid blocking operations).
Types ¶
type RateLimitService ¶
type RateLimitService interface {
Get(ctx context.Context) (*github.RateLimits, *github.Response, error)
}
RateLimitService defines the interface for rate limit operations. This allows for mocking in tests.
type RateLimitStatus ¶
type RateLimitStatus struct {
// Remaining is the number of requests remaining in the current rate limit window.
Remaining int
// Limit is the maximum number of requests allowed in the rate limit window.
Limit int
// ResetAt is when the rate limit will reset.
ResetAt time.Time
}
RateLimitStatus contains information about GitHub API rate limits.
func CheckRateLimit ¶
func CheckRateLimit(ctx context.Context) (*RateLimitStatus, error)
CheckRateLimit queries the GitHub API for current rate limit status. Returns nil status (not error) if the check fails, to avoid blocking operations.
func CheckRateLimitWithService ¶
func CheckRateLimitWithService(ctx context.Context, service RateLimitService) (*RateLimitStatus, error)
CheckRateLimitWithService queries the GitHub API using a custom service. This is primarily used for testing with mock services.