github

package
v1.203.0-rc.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func GetLatestRelease(owner string, repo string) (string, error)

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

func ShouldWaitForRateLimit(ctx context.Context, minRemaining int) bool

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

func WaitForRateLimit(ctx context.Context, minRemaining int) error

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.

type ReleasesOptions

type ReleasesOptions struct {
	Owner              string
	Repo               string
	Limit              int
	Offset             int
	IncludePrereleases bool
	Since              *time.Time
}

ReleasesOptions contains options for fetching GitHub releases.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL